(* Content-type: application/vnd.wolfram.mathematica *)

(*** Wolfram Notebook File ***)
(* http://www.wolfram.com/nb *)

(* CreatedBy='Mathematica 8.0' *)

(*CacheID: 234*)
(* Internal cache information:
NotebookFileLineBreakTest
NotebookFileLineBreakTest
NotebookDataPosition[       157,          7]
NotebookDataLength[    414509,      10181]
NotebookOptionsPosition[    404699,       9887]
NotebookOutlinePosition[    405134,       9904]
CellTagsIndexPosition[    405091,       9901]
WindowFrame->Normal*)

(* Beginning of Notebook Content *)
Notebook[{

Cell[CellGroupData[{
Cell["Code formatting examples ", "Section",
 CellChangeTimes->{{3.539876535071289*^9, 3.5398765371708984`*^9}, {
  3.540401492732769*^9, 3.540401501327884*^9}, {3.540401808581986*^9, 
  3.540401808654826*^9}},
 FontWeight->"Plain"],

Cell["\<\
I assembled a rather extensive set of examples, which, to my mind, show that \
the formatter is fairly robust, and we can move on, improving it further \
along the way.\
\>", "Text",
 CellChangeTimes->{{3.540401774618687*^9, 3.540401799660094*^9}}],

Cell[BoxData[
 RowBox[{
  RowBox[{"Needs", "[", "\"\<CodeFormatter`\>\"", "]"}], " "}]], "Input",
 InitializationCell->True,
 CellChangeTimes->{{3.540387567609852*^9, 3.540387587032259*^9}, {
  3.540401509026651*^9, 3.540401512012421*^9}}],

Cell[BoxData[
 RowBox[{
  RowBox[{"prn", " ", "=", " ", 
   RowBox[{
    RowBox[{"CellPrint", "[", 
     RowBox[{"Cell", "[", 
      RowBox[{
       RowBox[{"BoxData", "[", "#", "]"}], ",", "\"\<Input\>\""}], "]"}], 
     "]"}], "&"}]}], ";"}]], "Input",
 InitializationCell->True],

Cell[CellGroupData[{

Cell["\<\
An experiment with comments (comments not fully supported yet)\
\>", "Subsubsection",
 CellChangeTimes->{{3.5398767920625*^9, 3.5398768085859375`*^9}}],

Cell[BoxData[
 RowBox[{"prn", "@", 
  RowBox[{"FullCodeFormat", "@", 
   RowBox[{"MakeBoxes", "@", 
    RowBox[{"If", "[", "\t\t\t", "\n", "\t", 
     RowBox[{
      RowBox[{
       RowBox[{
       "indexHash", "\[LeftDoubleBracket]", "index", 
        "\[RightDoubleBracket]"}], "\[Equal]", "0"}], ",", 
      RowBox[{
       RowBox[{
        RowBox[{
        "indexHash", "\[LeftDoubleBracket]", "index", 
         "\[RightDoubleBracket]"}], "=", "1"}], ";", 
       RowBox[{
        RowBox[{"resultIndices", "\[LeftDoubleBracket]", 
         RowBox[{"++", "ctr"}], "\[RightDoubleBracket]"}], "=", "index"}]}], 
      ",", 
      RowBox[{
       RowBox[{"indexHash", "[", 
        RowBox[{"[", 
         RowBox[{"index", "+", "1"}], "]"}], "]"}], "=", "0"}]}], "\n", 
     "]"}]}]}]}]], "Input",
 CellChangeTimes->{{3.5398768197822266`*^9, 3.5398768263847656`*^9}, {
  3.540387558498444*^9, 3.540387558817596*^9}, {3.540387602695869*^9, 
  3.540387603433409*^9}}],

Cell[BoxData[
 RowBox[{"If", "[", "\n", "\t", 
  RowBox[{
   RowBox[{
    RowBox[{
    "indexHash", "\[LeftDoubleBracket]", "index", "\[RightDoubleBracket]"}], 
    "\[Equal]", "0"}], ",", "\n", "\t", 
   RowBox[{
    RowBox[{
     RowBox[{
     "indexHash", "\[LeftDoubleBracket]", "index", "\[RightDoubleBracket]"}], 
     "=", "1"}], ";", 
    RowBox[{
     RowBox[{"resultIndices", "\[LeftDoubleBracket]", 
      RowBox[{"++", "ctr"}], "\[RightDoubleBracket]"}], "=", "index"}]}], ",",
    "\n", "\t", 
   RowBox[{"(*", " ", "else", " ", "*)"}], "\n", "\t", 
   RowBox[{
    RowBox[{"indexHash", "\[LeftDoubleBracket]", 
     RowBox[{"index", "+", "1"}], "\[RightDoubleBracket]"}], "=", "0"}]}], 
  "\n", "]"}]], "Input",
 GeneratedCell->True,
 CellAutoOverwrite->True,
 CellChangeTimes->{3.540387605023232*^9}]
}, Closed]],

Cell[CellGroupData[{

Cell["Example1", "Subsubsection",
 CellChangeTimes->{{3.5391550382490234`*^9, 3.539155038955078*^9}, 
   3.540401561827656*^9}],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"boxes", " ", "=", " ", 
  RowBox[{"MakeBoxes", "[", "\[IndentingNewLine]", 
   RowBox[{
    RowBox[{"Clear", "[", "a", "]"}], ";", 
    RowBox[{
     RowBox[{"f", "[", "x_", "]"}], ":=", 
     RowBox[{"Module", "[", 
      RowBox[{
       RowBox[{"{", 
        RowBox[{"y", "=", "x"}], "}"}], ",", "\[IndentingNewLine]", 
       RowBox[{"myFunction", "[", "\[IndentingNewLine]", 
        RowBox[{
         RowBox[{
          RowBox[{"resultIndices", "[", 
           RowBox[{"[", 
            RowBox[{"++", "ctr"}], "]"}], "]"}], "=", 
          RowBox[{"resultIndices", "[", 
           RowBox[{"[", 
            RowBox[{"++", "ctr"}], "]"}], "]"}]}], ";"}], "]"}]}], "]"}]}]}], 
   "]"}]}]], "Input",
 CellChangeTimes->{{3.5398771964335938`*^9, 3.5398772176416016`*^9}}],

Cell[BoxData[
 RowBox[{"RowBox", "[", 
  RowBox[{"{", 
   RowBox[{
    RowBox[{"RowBox", "[", 
     RowBox[{"{", 
      RowBox[{"\<\"Clear\"\>", ",", "\<\"[\"\>", ",", "\<\"a\"\>", 
       ",", "\<\"]\"\>"}], "}"}], "]"}], ",", "\<\";\"\>", ",", 
    RowBox[{"RowBox", "[", 
     RowBox[{"{", 
      RowBox[{
       RowBox[{"RowBox", "[", 
        RowBox[{"{", 
         RowBox[{"\<\"f\"\>", ",", "\<\"[\"\>", ",", "\<\"x_\"\>", 
          ",", "\<\"]\"\>"}], "}"}], "]"}], ",", "\<\":=\"\>", ",", 
       RowBox[{"RowBox", "[", 
        RowBox[{"{", 
         RowBox[{"\<\"Module\"\>", ",", "\<\"[\"\>", ",", 
          RowBox[{"RowBox", "[", 
           RowBox[{"{", 
            RowBox[{
             RowBox[{"RowBox", "[", 
              RowBox[{"{", 
               RowBox[{"\<\"{\"\>", ",", 
                RowBox[{"RowBox", "[", 
                 RowBox[{"{", 
                  RowBox[{"\<\"y\"\>", ",", "\<\"=\"\>", ",", "\<\"x\"\>"}], 
                  "}"}], "]"}], ",", "\<\"}\"\>"}], "}"}], "]"}], 
             ",", "\<\",\"\>", ",", 
             RowBox[{"RowBox", "[", 
              RowBox[{"{", 
               RowBox[{"\<\"myFunction\"\>", ",", "\<\"[\"\>", ",", 
                RowBox[{"RowBox", "[", 
                 RowBox[{"{", 
                  RowBox[{
                   RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"resultIndices\"\>", 
                    ",", "\<\"\[LeftDoubleBracket]\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"++\"\>", ",", "\<\"ctr\"\>"}], "}"}], "]"}], 
                    ",", "\<\"\[RightDoubleBracket]\"\>"}], "}"}], "]"}], 
                    ",", "\<\"=\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"resultIndices\"\>", 
                    ",", "\<\"\[LeftDoubleBracket]\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"++\"\>", ",", "\<\"ctr\"\>"}], "}"}], "]"}], 
                    ",", "\<\"\[RightDoubleBracket]\"\>"}], "}"}], "]"}]}], 
                    "}"}], "]"}], ",", "\<\";\"\>"}], "}"}], "]"}], 
                ",", "\<\"]\"\>"}], "}"}], "]"}]}], "}"}], "]"}], 
          ",", "\<\"]\"\>"}], "}"}], "]"}]}], "}"}], "]"}]}], "}"}], 
  "]"}]], "Output",
 CellChangeTimes->{3.5398772191210938`*^9, 3.54030637000332*^9, 
  3.540387623539931*^9, 3.54038767425146*^9, 3.540401642579062*^9}]
}, Open  ]],

Cell[BoxData[
 RowBox[{"prn", "@", 
  RowBox[{"FullCodeFormat", "@", "boxes"}]}]], "Input",
 CellChangeTimes->{{3.538744911366211*^9, 3.538744985350586*^9}, {
   3.538745087064453*^9, 3.5387451694560547`*^9}, 3.538745317541992*^9, {
   3.5398766566640625`*^9, 3.5398766611552734`*^9}, {3.5398771895302734`*^9, 
   3.539877224533203*^9}, 3.540387641306317*^9}],

Cell[BoxData[
 RowBox[{"\n", 
  RowBox[{
   RowBox[{
    RowBox[{"Clear", "[", "a", "]"}], ";"}], "\n", 
   RowBox[{
    RowBox[{"f", "[", "x_", "]"}], ":=", "\n", "\t", 
    RowBox[{"Module", "[", 
     RowBox[{
      RowBox[{"{", 
       RowBox[{"y", "=", "x"}], "}"}], ",", "\n", "\t", "\t", 
      RowBox[{"myFunction", "[", 
       RowBox[{
        RowBox[{
         RowBox[{"resultIndices", "\[LeftDoubleBracket]", 
          RowBox[{"++", "ctr"}], "\[RightDoubleBracket]"}], "=", 
         RowBox[{"resultIndices", "\[LeftDoubleBracket]", 
          RowBox[{"++", "ctr"}], "\[RightDoubleBracket]"}]}], ";"}], "]"}]}], 
     "\n", "\t", "]"}]}]}]}]], "Input",
 GeneratedCell->True,
 CellAutoOverwrite->True,
 CellChangeTimes->{3.54030637137939*^9}],

Cell[BoxData[
 RowBox[{"prn", "@", 
  RowBox[{"FullCodeFormatCompact", "@", "boxes"}]}]], "Input",
 CellChangeTimes->{{3.5398772313847656`*^9, 3.5398772324833984`*^9}, 
   3.540387641369846*^9}],

Cell[BoxData[
 RowBox[{"\n", 
  RowBox[{
   RowBox[{
    RowBox[{"Clear", "[", "a", "]"}], ";"}], "\n", 
   RowBox[{
    RowBox[{"f", "[", "x_", "]"}], ":=", "\n", "\t", 
    RowBox[{"Module", "[", 
     RowBox[{
      RowBox[{"{", 
       RowBox[{"y", "=", "x"}], "}"}], ",", "\n", "\t", "\t", 
      RowBox[{"myFunction", "[", 
       RowBox[{
        RowBox[{
         RowBox[{"resultIndices", "\[LeftDoubleBracket]", 
          RowBox[{"++", "ctr"}], "\[RightDoubleBracket]"}], "=", 
         RowBox[{"resultIndices", "\[LeftDoubleBracket]", 
          RowBox[{"++", "ctr"}], "\[RightDoubleBracket]"}]}], ";"}], "]"}]}], 
     "]"}]}]}]}]], "Input",
 GeneratedCell->True,
 CellAutoOverwrite->True,
 CellChangeTimes->{3.540387714942444*^9}]
}, Closed]],

Cell[CellGroupData[{

Cell["Example2", "Subsubsection",
 CellChangeTimes->{{3.5391551239716797`*^9, 3.5391551254921875`*^9}, 
   3.540401563608322*^9}],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"boxes0", " ", "=", " ", "\[IndentingNewLine]", 
  RowBox[{"MakeBoxes", "[", "\[IndentingNewLine]", 
   RowBox[{
    RowBox[{"ClearAll", "[", "generateFastMean", "]"}], ";", "\n", 
    RowBox[{
     RowBox[{"generateFastMean", "[", 
      RowBox[{"maxIndex_Integer", "?", "Positive"}], "]"}], ":=", 
     RowBox[{"Compile", "[", 
      RowBox[{
       RowBox[{"{", 
        RowBox[{"{", 
         RowBox[{"data", ",", "_Real", ",", "2"}], "}"}], "}"}], ",", 
       RowBox[{"Module", "[", 
        RowBox[{
         RowBox[{"{", 
          RowBox[{
           RowBox[{"means", "=", 
            RowBox[{"Table", "[", 
             RowBox[{"0.", ",", 
              RowBox[{"{", "maxIndex", "}"}]}], "]"}]}], ",", 
           RowBox[{"num", "=", 
            RowBox[{"Table", "[", 
             RowBox[{"0", ",", 
              RowBox[{"{", "maxIndex", "}"}]}], "]"}]}], ",", 
           RowBox[{"ctr", "=", "0"}], ",", 
           RowBox[{"i", "=", "0"}], ",", 
           RowBox[{"index", "=", "0"}], ",", 
           RowBox[{"resultIndices", "=", 
            RowBox[{"Table", "[", 
             RowBox[{"0", ",", 
              RowBox[{"{", "maxIndex", "}"}]}], "]"}]}], ",", 
           RowBox[{"indexHash", "=", 
            RowBox[{"Table", "[", 
             RowBox[{"0", ",", 
              RowBox[{"{", "maxIndex", "}"}]}], "]"}]}]}], "}"}], ",", 
         RowBox[{
          RowBox[{"Do", "[", 
           RowBox[{
            RowBox[{
             RowBox[{"index", "=", 
              RowBox[{"IntegerPart", "[", 
               RowBox[{"data", "[", 
                RowBox[{"[", 
                 RowBox[{"i", ",", "2"}], "]"}], "]"}], "]"}]}], ";", 
             "\[IndentingNewLine]", 
             RowBox[{
              RowBox[{"means", "[", 
               RowBox[{"[", "index", "]"}], "]"}], "+=", 
              RowBox[{"data", "[", 
               RowBox[{"[", 
                RowBox[{"i", ",", "1"}], "]"}], "]"}]}], ";", 
             "\[IndentingNewLine]", 
             RowBox[{
              RowBox[{"num", "[", 
               RowBox[{"[", "index", "]"}], "]"}], "++"}], ";", 
             "\[IndentingNewLine]", 
             RowBox[{"If", "[", 
              RowBox[{
               RowBox[{
                RowBox[{"indexHash", "[", 
                 RowBox[{"[", "index", "]"}], "]"}], "\[Equal]", "0"}], ",", 
               RowBox[{
                RowBox[{
                 RowBox[{"indexHash", "[", 
                  RowBox[{"[", "index", "]"}], "]"}], "=", "1"}], ";", 
                "\[IndentingNewLine]", 
                RowBox[{
                 RowBox[{"resultIndices", "[", 
                  RowBox[{"[", 
                   RowBox[{"++", "ctr"}], "]"}], "]"}], "=", "index"}]}]}], 
              "]"}], ";"}], ",", 
            RowBox[{"{", 
             RowBox[{"i", ",", 
              RowBox[{"Length", "[", "data", "]"}]}], "}"}]}], "]"}], ";", 
          "\[IndentingNewLine]", 
          RowBox[{"resultIndices", "=", 
           RowBox[{"Take", "[", 
            RowBox[{"resultIndices", ",", "ctr"}], "]"}]}], ";", 
          "\[IndentingNewLine]", 
          RowBox[{"Transpose", "[", 
           RowBox[{"{", 
            RowBox[{"resultIndices", ",", 
             RowBox[{
              RowBox[{"means", "[", 
               RowBox[{"[", "resultIndices", "]"}], "]"}], "+", 
              RowBox[{"num", "[", 
               RowBox[{"[", "resultIndices", "]"}], "]"}]}]}], "}"}], 
           "]"}]}]}], "]"}], ",", 
       RowBox[{"(*", "Module", "*)"}], 
       RowBox[{"CompilationTarget", "\[Rule]", "\"\<C\>\""}], ",", 
       RowBox[{"RuntimeOptions", "\[Rule]", "\"\<Speed\>\""}]}], "]"}]}], 
    ";"}], "]"}]}]], "Input",
 CellChangeTimes->{{3.538073492669922*^9, 3.5380735040498047`*^9}, {
   3.5380735499609375`*^9, 3.5380735821572266`*^9}, {3.5391551349746094`*^9, 
   3.539155151995117*^9}, {3.5391589632373047`*^9, 3.539158966623047*^9}, 
   3.5398768399101562`*^9, 3.5398769497333984`*^9}],

Cell[BoxData[
 RowBox[{"RowBox", "[", 
  RowBox[{"{", 
   RowBox[{
    RowBox[{"RowBox", "[", 
     RowBox[{"{", 
      RowBox[{"\<\"ClearAll\"\>", ",", "\<\"[\"\>", 
       ",", "\<\"generateFastMean\"\>", ",", "\<\"]\"\>"}], "}"}], "]"}], 
    ",", "\<\";\"\>", ",", 
    RowBox[{"RowBox", "[", 
     RowBox[{"{", 
      RowBox[{
       RowBox[{"RowBox", "[", 
        RowBox[{"{", 
         RowBox[{"\<\"generateFastMean\"\>", ",", "\<\"[\"\>", ",", 
          RowBox[{"RowBox", "[", 
           RowBox[{"{", 
            
            RowBox[{"\<\"maxIndex_Integer\"\>", ",", "\<\"?\"\>", 
             ",", "\<\"Positive\"\>"}], "}"}], "]"}], ",", "\<\"]\"\>"}], 
         "}"}], "]"}], ",", "\<\":=\"\>", ",", 
       RowBox[{"RowBox", "[", 
        RowBox[{"{", 
         RowBox[{"\<\"Compile\"\>", ",", "\<\"[\"\>", ",", 
          RowBox[{"RowBox", "[", 
           RowBox[{"{", 
            RowBox[{
             RowBox[{"RowBox", "[", 
              RowBox[{"{", 
               RowBox[{"\<\"{\"\>", ",", 
                RowBox[{"RowBox", "[", 
                 RowBox[{"{", 
                  RowBox[{"\<\"{\"\>", ",", 
                   RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"data\"\>", ",", "\<\",\"\>", 
                    ",", "\<\"_Real\"\>", ",", "\<\",\"\>", 
                    ",", "\<\"2\"\>"}], "}"}], "]"}], ",", "\<\"}\"\>"}], 
                  "}"}], "]"}], ",", "\<\"}\"\>"}], "}"}], "]"}], 
             ",", "\<\",\"\>", ",", 
             RowBox[{"RowBox", "[", 
              RowBox[{"{", 
               RowBox[{"\<\"Module\"\>", ",", "\<\"[\"\>", ",", 
                RowBox[{"RowBox", "[", 
                 RowBox[{"{", 
                  RowBox[{
                   RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"{\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"means\"\>", ",", "\<\"=\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"Table\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"0.`\"\>", ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"{\"\>", ",", "\<\"maxIndex\"\>", 
                    ",", "\<\"}\"\>"}], "}"}], "]"}]}], "}"}], "]"}], 
                    ",", "\<\"]\"\>"}], "}"}], "]"}]}], "}"}], "]"}], 
                    ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"num\"\>", ",", "\<\"=\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"Table\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"0\"\>", ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"{\"\>", ",", "\<\"maxIndex\"\>", 
                    ",", "\<\"}\"\>"}], "}"}], "]"}]}], "}"}], "]"}], 
                    ",", "\<\"]\"\>"}], "}"}], "]"}]}], "}"}], "]"}], 
                    ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"ctr\"\>", ",", "\<\"=\"\>", 
                    ",", "\<\"0\"\>"}], "}"}], "]"}], ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"i\"\>", ",", "\<\"=\"\>", ",", "\<\"0\"\>"}],
                     "}"}], "]"}], ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"index\"\>", ",", "\<\"=\"\>", 
                    ",", "\<\"0\"\>"}], "}"}], "]"}], ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"resultIndices\"\>", ",", "\<\"=\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"Table\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"0\"\>", ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"{\"\>", ",", "\<\"maxIndex\"\>", 
                    ",", "\<\"}\"\>"}], "}"}], "]"}]}], "}"}], "]"}], 
                    ",", "\<\"]\"\>"}], "}"}], "]"}]}], "}"}], "]"}], 
                    ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"indexHash\"\>", ",", "\<\"=\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"Table\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"0\"\>", ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"{\"\>", ",", "\<\"maxIndex\"\>", 
                    ",", "\<\"}\"\>"}], "}"}], "]"}]}], "}"}], "]"}], 
                    ",", "\<\"]\"\>"}], "}"}], "]"}]}], "}"}], "]"}]}], "}"}],
                     "]"}], ",", "\<\"}\"\>"}], "}"}], "]"}], 
                   ",", "\<\",\"\>", ",", 
                   RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"Do\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"index\"\>", ",", "\<\"=\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"IntegerPart\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"data\"\>", 
                    ",", "\<\"\[LeftDoubleBracket]\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"i\"\>", ",", "\<\",\"\>", ",", "\<\"2\"\>"}],
                     "}"}], "]"}], ",", "\<\"\[RightDoubleBracket]\"\>"}], 
                    "}"}], "]"}], ",", "\<\"]\"\>"}], "}"}], "]"}]}], "}"}], 
                    "]"}], ",", "\<\";\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"means\"\>", 
                    ",", "\<\"\[LeftDoubleBracket]\"\>", ",", "\<\"index\"\>",
                     ",", "\<\"\[RightDoubleBracket]\"\>"}], "}"}], "]"}], 
                    ",", "\<\"+=\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"data\"\>", 
                    ",", "\<\"\[LeftDoubleBracket]\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"i\"\>", ",", "\<\",\"\>", ",", "\<\"1\"\>"}],
                     "}"}], "]"}], ",", "\<\"\[RightDoubleBracket]\"\>"}], 
                    "}"}], "]"}]}], "}"}], "]"}], ",", "\<\";\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"num\"\>", 
                    ",", "\<\"\[LeftDoubleBracket]\"\>", ",", "\<\"index\"\>",
                     ",", "\<\"\[RightDoubleBracket]\"\>"}], "}"}], "]"}], 
                    ",", "\<\"++\"\>"}], "}"}], "]"}], ",", "\<\";\"\>", ",", 
                    
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"If\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"indexHash\"\>", 
                    ",", "\<\"\[LeftDoubleBracket]\"\>", ",", "\<\"index\"\>",
                     ",", "\<\"\[RightDoubleBracket]\"\>"}], "}"}], "]"}], 
                    ",", "\<\"\[Equal]\"\>", ",", "\<\"0\"\>"}], "}"}], "]"}],
                     ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"indexHash\"\>", 
                    ",", "\<\"\[LeftDoubleBracket]\"\>", ",", "\<\"index\"\>",
                     ",", "\<\"\[RightDoubleBracket]\"\>"}], "}"}], "]"}], 
                    ",", "\<\"=\"\>", ",", "\<\"1\"\>"}], "}"}], "]"}], 
                    ",", "\<\";\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"resultIndices\"\>", 
                    ",", "\<\"\[LeftDoubleBracket]\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"++\"\>", ",", "\<\"ctr\"\>"}], "}"}], "]"}], 
                    ",", "\<\"\[RightDoubleBracket]\"\>"}], "}"}], "]"}], 
                    ",", "\<\"=\"\>", ",", "\<\"index\"\>"}], "}"}], "]"}]}], 
                    "}"}], "]"}]}], "}"}], "]"}], ",", "\<\"]\"\>"}], "}"}], 
                    "]"}], ",", "\<\";\"\>"}], "}"}], "]"}], ",", "\<\",\"\>",
                     ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"{\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"i\"\>", ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"Length\"\>", ",", "\<\"[\"\>", 
                    ",", "\<\"data\"\>", ",", "\<\"]\"\>"}], "}"}], "]"}]}], 
                    "}"}], "]"}], ",", "\<\"}\"\>"}], "}"}], "]"}]}], "}"}], 
                    "]"}], ",", "\<\"]\"\>"}], "}"}], "]"}], ",", "\<\";\"\>",
                     ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"resultIndices\"\>", ",", "\<\"=\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"Take\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"resultIndices\"\>", ",", "\<\",\"\>", 
                    ",", "\<\"ctr\"\>"}], "}"}], "]"}], ",", "\<\"]\"\>"}], 
                    "}"}], "]"}]}], "}"}], "]"}], ",", "\<\";\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"Transpose\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"{\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"resultIndices\"\>", ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"means\"\>", 
                    ",", "\<\"\[LeftDoubleBracket]\"\>", 
                    ",", "\<\"resultIndices\"\>", 
                    ",", "\<\"\[RightDoubleBracket]\"\>"}], "}"}], "]"}], 
                    ",", "\<\"+\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"num\"\>", 
                    ",", "\<\"\[LeftDoubleBracket]\"\>", 
                    ",", "\<\"resultIndices\"\>", 
                    ",", "\<\"\[RightDoubleBracket]\"\>"}], "}"}], "]"}]}], 
                    "}"}], "]"}]}], "}"}], "]"}], ",", "\<\"}\"\>"}], "}"}], 
                    "]"}], ",", "\<\"]\"\>"}], "}"}], "]"}]}], "}"}], "]"}]}],
                   "}"}], "]"}], ",", "\<\"]\"\>"}], "}"}], "]"}], 
             ",", "\<\",\"\>", ",", 
             RowBox[{"RowBox", "[", 
              RowBox[{"{", 
               
               RowBox[{"\<\"CompilationTarget\"\>", ",", "\<\"\[Rule]\"\>", 
                ",", "\<\"\\\"C\\\"\"\>"}], "}"}], "]"}], ",", "\<\",\"\>", 
             ",", 
             RowBox[{"RowBox", "[", 
              RowBox[{"{", 
               
               RowBox[{"\<\"RuntimeOptions\"\>", ",", "\<\"\[Rule]\"\>", 
                ",", "\<\"\\\"Speed\\\"\"\>"}], "}"}], "]"}]}], "}"}], "]"}], 
          ",", "\<\"]\"\>"}], "}"}], "]"}]}], "}"}], "]"}], 
    ",", "\<\";\"\>"}], "}"}], "]"}]], "Output",
 CellChangeTimes->{3.5398769501220703`*^9, 3.540387921190284*^9, 
  3.540401669214467*^9}]
}, Open  ]],

Cell[BoxData[
 RowBox[{"prn", "@", 
  RowBox[{"FullCodeFormat", "@", "boxes0"}]}]], "Input",
 CellChangeTimes->{
  3.538073532786133*^9, {3.539876857970703*^9, 3.5398768591054688`*^9}, 
   3.540387641410295*^9}],

Cell[BoxData[
 RowBox[{"\n", 
  RowBox[{
   RowBox[{
    RowBox[{"ClearAll", "[", "generateFastMean", "]"}], ";"}], "\n", 
   RowBox[{
    RowBox[{
     RowBox[{"generateFastMean", "[", 
      RowBox[{"maxIndex_Integer", "?", "Positive"}], "]"}], ":=", "\n", "\t", 
     
     RowBox[{"Compile", "[", "\t", "\t", "\n", "\t", "\t", 
      RowBox[{
       RowBox[{"{", 
        RowBox[{"{", 
         RowBox[{"data", ",", "_Real", ",", "2"}], "}"}], "}"}], ",", "\n", 
       "\t", "\t", 
       RowBox[{"Module", "[", "\n", "\t", "\t", 
        RowBox[{
         RowBox[{"{", "\t", "\t", "\t", "\n", "\t", "\t", "\t", 
          RowBox[{
           RowBox[{"means", "=", 
            RowBox[{"Table", "[", 
             RowBox[{"0.`", ",", 
              RowBox[{"{", "maxIndex", "}"}]}], "]"}]}], ",", "\n", "\t", 
           "\t", "\t", 
           RowBox[{"num", "=", 
            RowBox[{"Table", "[", 
             RowBox[{"0", ",", 
              RowBox[{"{", "maxIndex", "}"}]}], "]"}]}], ",", "\n", "\t", 
           "\t", "\t", 
           RowBox[{"ctr", "=", "0"}], ",", "\n", "\t", "\t", "\t", 
           RowBox[{"i", "=", "0"}], ",", "\n", "\t", "\t", "\t", 
           RowBox[{"index", "=", "0"}], ",", "\n", "\t", "\t", "\t", 
           RowBox[{"resultIndices", "=", 
            RowBox[{"Table", "[", 
             RowBox[{"0", ",", 
              RowBox[{"{", "maxIndex", "}"}]}], "]"}]}], ",", "\n", "\t", 
           "\t", "\t", 
           RowBox[{"indexHash", "=", 
            RowBox[{"Table", "[", 
             RowBox[{"0", ",", 
              RowBox[{"{", "maxIndex", "}"}]}], "]"}]}]}], "\n", "\t", "\t", 
          "}"}], ",", "\t", "\t", "\t", "\n", "\t", "\t", "\t", 
         RowBox[{
          RowBox[{
          "Do", "[", "\t", "\t", "\t", "\t", "\t", "\t", "\t", "\t", "\n", 
           "\t", "\t", "\t", "\t", 
           RowBox[{
            RowBox[{
             RowBox[{"index", "=", 
              RowBox[{"IntegerPart", "[", 
               RowBox[{"data", "\[LeftDoubleBracket]", 
                RowBox[{"i", ",", "2"}], "\[RightDoubleBracket]"}], "]"}]}], 
             ";", "\n", "\t", "\t", "\t", "\t", 
             RowBox[{
              RowBox[{
              "means", "\[LeftDoubleBracket]", "index", 
               "\[RightDoubleBracket]"}], "+=", 
              RowBox[{"data", "\[LeftDoubleBracket]", 
               RowBox[{"i", ",", "1"}], "\[RightDoubleBracket]"}]}], ";", 
             "\n", "\t", "\t", "\t", "\t", 
             RowBox[{
              RowBox[{
              "num", "\[LeftDoubleBracket]", "index", 
               "\[RightDoubleBracket]"}], "++"}], ";", "\n", "\t", "\t", "\t",
              "\t", 
             RowBox[{
             "If", "[", "\t", "\t", "\t", "\t", "\t", "\n", "\t", "\t", "\t", 
              "\t", "\t", 
              RowBox[{
               RowBox[{
                RowBox[{
                "indexHash", "\[LeftDoubleBracket]", "index", 
                 "\[RightDoubleBracket]"}], "\[Equal]", "0"}], ",", "\n", 
               "\t", "\t", "\t", "\t", "\t", 
               RowBox[{
                RowBox[{
                 RowBox[{
                 "indexHash", "\[LeftDoubleBracket]", "index", 
                  "\[RightDoubleBracket]"}], "=", "1"}], ";", 
                RowBox[{
                 RowBox[{"resultIndices", "\[LeftDoubleBracket]", 
                  RowBox[{"++", "ctr"}], "\[RightDoubleBracket]"}], "=", 
                 "index"}]}]}], "\n", "\t", "\t", "\t", "\t", "]"}], ";"}], 
            ",", "\n", "\t", "\t", "\t", "\t", 
            RowBox[{"{", 
             RowBox[{"i", ",", 
              RowBox[{"Length", "[", "data", "]"}]}], "}"}]}], "\n", "\t", 
           "\t", "\t", "]"}], ";", "\n", "\t", "\t", "\t", 
          RowBox[{"resultIndices", "=", 
           RowBox[{"Take", "[", 
            RowBox[{"resultIndices", ",", "ctr"}], "]"}]}], ";", "\n", "\t", 
          "\t", "\t", 
          RowBox[{"Transpose", "[", "\n", "\t", "\t", "\t", "\t", 
           RowBox[{
           "{", "\t", "\t", "\t", "\t", "\t", "\n", "\t", "\t", "\t", "\t", 
            "\t", 
            RowBox[{
            "resultIndices", ",", "\n", "\t", "\t", "\t", "\t", "\t", 
             RowBox[{
              RowBox[{
              "means", "\[LeftDoubleBracket]", "resultIndices", 
               "\[RightDoubleBracket]"}], "+", 
              RowBox[{
              "num", "\[LeftDoubleBracket]", "resultIndices", 
               "\[RightDoubleBracket]"}]}]}], "\n", "\t", "\t", "\t", "\t", 
            "}"}], "\n", "\t", "\t", "\t", "]"}]}]}], "\n", "\t", "\t", "]"}],
        ",", "\n", "\t", "\t", 
       RowBox[{"CompilationTarget", "\[Rule]", "\"\<C\>\""}], ",", "\n", "\t",
        "\t", 
       RowBox[{"RuntimeOptions", "\[Rule]", "\"\<Speed\>\""}]}], "\n", "\t", 
      "]"}]}], ";"}]}]}]], "Input",
 GeneratedCell->True,
 CellAutoOverwrite->True,
 CellChangeTimes->{3.540401671748701*^9}],

Cell[BoxData[
 RowBox[{"prn", "@", 
  RowBox[{"FullCodeFormatCompact", "@", "boxes0"}]}]], "Input",
 CellChangeTimes->{{3.5398772557285156`*^9, 3.539877256830078*^9}, 
   3.540387641462608*^9}],

Cell[BoxData[
 RowBox[{"\n", 
  RowBox[{
   RowBox[{
    RowBox[{"ClearAll", "[", "generateFastMean", "]"}], ";"}], "\n", 
   RowBox[{
    RowBox[{
     RowBox[{"generateFastMean", "[", 
      RowBox[{"maxIndex_Integer", "?", "Positive"}], "]"}], ":=", "\n", "\t", 
     
     RowBox[{"Compile", "[", "\t", "\t", "\n", "\t", "\t", 
      RowBox[{
       RowBox[{"{", 
        RowBox[{"{", 
         RowBox[{"data", ",", "_Real", ",", "2"}], "}"}], "}"}], ",", "\n", 
       "\t", "\t", 
       RowBox[{"Module", "[", "\n", "\t", "\t", 
        RowBox[{
         RowBox[{"{", "\t", "\t", "\t", "\n", "\t", "\t", "\t", 
          RowBox[{
           RowBox[{"means", "=", 
            RowBox[{"Table", "[", 
             RowBox[{"0.`", ",", 
              RowBox[{"{", "maxIndex", "}"}]}], "]"}]}], ",", "\n", "\t", 
           "\t", "\t", 
           RowBox[{"num", "=", 
            RowBox[{"Table", "[", 
             RowBox[{"0", ",", 
              RowBox[{"{", "maxIndex", "}"}]}], "]"}]}], ",", "\n", "\t", 
           "\t", "\t", 
           RowBox[{"ctr", "=", "0"}], ",", "\n", "\t", "\t", "\t", 
           RowBox[{"i", "=", "0"}], ",", "\n", "\t", "\t", "\t", 
           RowBox[{"index", "=", "0"}], ",", "\n", "\t", "\t", "\t", 
           RowBox[{"resultIndices", "=", 
            RowBox[{"Table", "[", 
             RowBox[{"0", ",", 
              RowBox[{"{", "maxIndex", "}"}]}], "]"}]}], ",", "\n", "\t", 
           "\t", "\t", 
           RowBox[{"indexHash", "=", 
            RowBox[{"Table", "[", 
             RowBox[{"0", ",", 
              RowBox[{"{", "maxIndex", "}"}]}], "]"}]}]}], "}"}], ",", "\t", 
         "\t", "\t", "\n", "\t", "\t", "\t", 
         RowBox[{
          RowBox[{
          "Do", "[", "\t", "\t", "\t", "\t", "\t", "\t", "\t", "\t", "\n", 
           "\t", "\t", "\t", "\t", 
           RowBox[{
            RowBox[{
             RowBox[{"index", "=", 
              RowBox[{"IntegerPart", "[", 
               RowBox[{"data", "\[LeftDoubleBracket]", 
                RowBox[{"i", ",", "2"}], "\[RightDoubleBracket]"}], "]"}]}], 
             ";", "\n", "\t", "\t", "\t", "\t", 
             RowBox[{
              RowBox[{
              "means", "\[LeftDoubleBracket]", "index", 
               "\[RightDoubleBracket]"}], "+=", 
              RowBox[{"data", "\[LeftDoubleBracket]", 
               RowBox[{"i", ",", "1"}], "\[RightDoubleBracket]"}]}], ";", 
             "\n", "\t", "\t", "\t", "\t", 
             RowBox[{
              RowBox[{
              "num", "\[LeftDoubleBracket]", "index", 
               "\[RightDoubleBracket]"}], "++"}], ";", "\n", "\t", "\t", "\t",
              "\t", 
             RowBox[{
             "If", "[", "\t", "\t", "\t", "\t", "\t", "\n", "\t", "\t", "\t", 
              "\t", "\t", 
              RowBox[{
               RowBox[{
                RowBox[{
                "indexHash", "\[LeftDoubleBracket]", "index", 
                 "\[RightDoubleBracket]"}], "\[Equal]", "0"}], ",", "\n", 
               "\t", "\t", "\t", "\t", "\t", 
               RowBox[{
                RowBox[{
                 RowBox[{
                 "indexHash", "\[LeftDoubleBracket]", "index", 
                  "\[RightDoubleBracket]"}], "=", "1"}], ";", 
                RowBox[{
                 RowBox[{"resultIndices", "\[LeftDoubleBracket]", 
                  RowBox[{"++", "ctr"}], "\[RightDoubleBracket]"}], "=", 
                 "index"}]}]}], "]"}], ";"}], ",", "\n", "\t", "\t", "\t", 
            "\t", 
            RowBox[{"{", 
             RowBox[{"i", ",", 
              RowBox[{"Length", "[", "data", "]"}]}], "}"}]}], "]"}], ";", 
          "\n", "\t", "\t", "\t", 
          RowBox[{"resultIndices", "=", 
           RowBox[{"Take", "[", 
            RowBox[{"resultIndices", ",", "ctr"}], "]"}]}], ";", "\n", "\t", 
          "\t", "\t", 
          RowBox[{"Transpose", "[", "\n", "\t", "\t", "\t", "\t", 
           RowBox[{
           "{", "\t", "\t", "\t", "\t", "\t", "\n", "\t", "\t", "\t", "\t", 
            "\t", 
            RowBox[{
            "resultIndices", ",", "\n", "\t", "\t", "\t", "\t", "\t", 
             RowBox[{
              RowBox[{
              "means", "\[LeftDoubleBracket]", "resultIndices", 
               "\[RightDoubleBracket]"}], "+", 
              RowBox[{
              "num", "\[LeftDoubleBracket]", "resultIndices", 
               "\[RightDoubleBracket]"}]}]}], "}"}], "]"}]}]}], "]"}], ",", 
       "\n", "\t", "\t", 
       RowBox[{"CompilationTarget", "\[Rule]", "\"\<C\>\""}], ",", "\n", "\t",
        "\t", 
       RowBox[{"RuntimeOptions", "\[Rule]", "\"\<Speed\>\""}]}], "]"}]}], 
    ";"}]}]}]], "Input",
 GeneratedCell->True,
 CellAutoOverwrite->True,
 CellChangeTimes->{3.540401679035092*^9}]
}, Closed]],

Cell[CellGroupData[{

Cell["Example3", "Subsubsection",
 CellChangeTimes->{{3.5391589884921875`*^9, 3.5391589897841797`*^9}, 
   3.540401564465898*^9}],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"boxes5", " ", "=", " ", 
  RowBox[{"MakeBoxes", "[", "\[IndentingNewLine]", 
   RowBox[{
    RowBox[{"Clear", "[", "getSamplesP", "]"}], ";", "\n", 
    RowBox[{
     RowBox[{"getSamplesP", "[", 
      RowBox[{"data_List", ",", 
       RowBox[{"minlen_Integer", "?", "Positive"}], ",", 
       RowBox[{"n", ":", 
        RowBox[{
         RowBox[{"(", 
          RowBox[{"_Integer", "|", "All"}], ")"}], ":", "All"}]}]}], "]"}], ":=", 
     RowBox[{"Select", "[", 
      RowBox[{
       RowBox[{
        RowBox[{
         RowBox[{"Transpose", "[", 
          RowBox[{"{", 
           RowBox[{"#", ",", 
            RowBox[{"Range", "[", 
             RowBox[{"Length", "[", "#", "]"}], "]"}]}], "}"}], "]"}], "&"}], 
        "@", 
        RowBox[{"Partition", "[", 
         RowBox[{"data", ",", "minlen", ",", "1"}], "]"}]}], ",", 
       RowBox[{
        RowBox[{"!", 
         RowBox[{"MemberQ", "[", 
          RowBox[{
           RowBox[{"First", "@", "#"}], ",", 
           RowBox[{"0", "|", "Null"}]}], "]"}]}], "&"}], ",", 
       RowBox[{"If", "[", 
        RowBox[{
         RowBox[{"n", "=!=", "All"}], ",", "n", ",", 
         RowBox[{"Sequence", "@@", 
          RowBox[{"{", "}"}]}]}], "]"}]}], "]"}]}]}], "]"}]}]], "Input",
 CellChangeTimes->{{3.5398769276533203`*^9, 3.539876938501953*^9}}],

Cell[BoxData[
 RowBox[{"RowBox", "[", 
  RowBox[{"{", 
   RowBox[{
    RowBox[{"RowBox", "[", 
     RowBox[{"{", 
      RowBox[{"\<\"Clear\"\>", ",", "\<\"[\"\>", ",", "\<\"getSamplesP\"\>", 
       ",", "\<\"]\"\>"}], "}"}], "]"}], ",", "\<\";\"\>", ",", 
    RowBox[{"RowBox", "[", 
     RowBox[{"{", 
      RowBox[{
       RowBox[{"RowBox", "[", 
        RowBox[{"{", 
         RowBox[{"\<\"getSamplesP\"\>", ",", "\<\"[\"\>", ",", 
          RowBox[{"RowBox", "[", 
           RowBox[{"{", 
            RowBox[{"\<\"data_List\"\>", ",", "\<\",\"\>", ",", 
             RowBox[{"RowBox", "[", 
              RowBox[{"{", 
               
               RowBox[{"\<\"minlen_Integer\"\>", ",", "\<\"?\"\>", 
                ",", "\<\"Positive\"\>"}], "}"}], "]"}], ",", "\<\",\"\>", 
             ",", 
             RowBox[{"RowBox", "[", 
              RowBox[{"{", 
               RowBox[{"\<\"n\"\>", ",", "\<\":\"\>", ",", 
                RowBox[{"RowBox", "[", 
                 RowBox[{"{", 
                  
                  RowBox[{"\<\"_Integer\"\>", ",", "\<\"|\"\>", 
                   ",", "\<\"All\"\>"}], "}"}], "]"}], ",", "\<\":\"\>", 
                ",", "\<\"All\"\>"}], "}"}], "]"}]}], "}"}], "]"}], 
          ",", "\<\"]\"\>"}], "}"}], "]"}], ",", "\<\":=\"\>", ",", 
       RowBox[{"RowBox", "[", 
        RowBox[{"{", 
         RowBox[{"\<\"Select\"\>", ",", "\<\"[\"\>", ",", 
          RowBox[{"RowBox", "[", 
           RowBox[{"{", 
            RowBox[{
             RowBox[{"RowBox", "[", 
              RowBox[{"{", 
               RowBox[{
                RowBox[{"RowBox", "[", 
                 RowBox[{"{", 
                  RowBox[{"\<\"(\"\>", ",", 
                   RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"Transpose\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"{\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"#1\"\>", ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"Range\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"Length\"\>", ",", "\<\"[\"\>", 
                    ",", "\<\"#1\"\>", ",", "\<\"]\"\>"}], "}"}], "]"}], 
                    ",", "\<\"]\"\>"}], "}"}], "]"}]}], "}"}], "]"}], 
                    ",", "\<\"}\"\>"}], "}"}], "]"}], ",", "\<\"]\"\>"}], 
                    "}"}], "]"}], ",", "\<\"&\"\>"}], "}"}], "]"}], 
                   ",", "\<\")\"\>"}], "}"}], "]"}], ",", "\<\"[\"\>", ",", 
                RowBox[{"RowBox", "[", 
                 RowBox[{"{", 
                  RowBox[{"\<\"Partition\"\>", ",", "\<\"[\"\>", ",", 
                   RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"data\"\>", ",", "\<\",\"\>", 
                    ",", "\<\"minlen\"\>", ",", "\<\",\"\>", 
                    ",", "\<\"1\"\>"}], "}"}], "]"}], ",", "\<\"]\"\>"}], 
                  "}"}], "]"}], ",", "\<\"]\"\>"}], "}"}], "]"}], 
             ",", "\<\",\"\>", ",", 
             RowBox[{"RowBox", "[", 
              RowBox[{"{", 
               RowBox[{
                RowBox[{"RowBox", "[", 
                 RowBox[{"{", 
                  RowBox[{"\<\"!\"\>", ",", 
                   RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"MemberQ\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"First\"\>", ",", "\<\"[\"\>", 
                    ",", "\<\"#1\"\>", ",", "\<\"]\"\>"}], "}"}], "]"}], 
                    ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"0\"\>", ",", "\<\"|\"\>", 
                    ",", "\<\"Null\"\>"}], "}"}], "]"}]}], "}"}], "]"}], 
                    ",", "\<\"]\"\>"}], "}"}], "]"}]}], "}"}], "]"}], 
                ",", "\<\"&\"\>"}], "}"}], "]"}], ",", "\<\",\"\>", ",", 
             RowBox[{"RowBox", "[", 
              RowBox[{"{", 
               RowBox[{"\<\"If\"\>", ",", "\<\"[\"\>", ",", 
                RowBox[{"RowBox", "[", 
                 RowBox[{"{", 
                  RowBox[{
                   RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"n\"\>", ",", "\<\"=!=\"\>", 
                    ",", "\<\"All\"\>"}], "}"}], "]"}], ",", "\<\",\"\>", 
                   ",", "\<\"n\"\>", ",", "\<\",\"\>", ",", 
                   RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"Sequence\"\>", ",", "\<\"@@\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"{\"\>", ",", "\<\"}\"\>"}], "}"}], "]"}]}], 
                    "}"}], "]"}]}], "}"}], "]"}], ",", "\<\"]\"\>"}], "}"}], 
              "]"}]}], "}"}], "]"}], ",", "\<\"]\"\>"}], "}"}], "]"}]}], 
      "}"}], "]"}]}], "}"}], "]"}]], "Output",
 CellChangeTimes->{3.5398769393779297`*^9, 3.540401727689076*^9}]
}, Open  ]],

Cell[BoxData[
 RowBox[{"prn", "@", 
  RowBox[{"FullCodeFormat", "@", "boxes5"}]}]], "Input",
 CellChangeTimes->{{3.537987332409242*^9, 3.5379873861914687`*^9}, {
   3.5398769148876953`*^9, 3.539876916279297*^9}, 3.540387641506598*^9}],

Cell[BoxData[
 RowBox[{"\n", 
  RowBox[{
   RowBox[{
    RowBox[{"Clear", "[", "getSamplesP", "]"}], ";"}], "\n", 
   RowBox[{
    RowBox[{"getSamplesP", "[", 
     RowBox[{"data_List", ",", 
      RowBox[{"minlen_Integer", "?", "Positive"}], ",", 
      RowBox[{"n", ":", 
       RowBox[{"_Integer", "|", "All"}], ":", "All"}]}], "]"}], ":=", "\n", 
    "\t", 
    RowBox[{"Select", "[", "\t", "\t", "\n", "\t", "\t", 
     RowBox[{
      RowBox[{
       RowBox[{"(", 
        RowBox[{
         RowBox[{"Transpose", "[", 
          RowBox[{"{", 
           RowBox[{"#1", ",", 
            RowBox[{"Range", "[", 
             RowBox[{"Length", "[", "#1", "]"}], "]"}]}], "}"}], "]"}], "&"}],
         ")"}], "[", 
       RowBox[{"Partition", "[", 
        RowBox[{"data", ",", "minlen", ",", "1"}], "]"}], "]"}], ",", "\n", 
      "\t", "\t", 
      RowBox[{
       RowBox[{"!", 
        RowBox[{"MemberQ", "[", 
         RowBox[{
          RowBox[{"First", "[", "#1", "]"}], ",", 
          RowBox[{"0", "|", "Null"}]}], "]"}]}], "&"}], ",", "\n", "\t", "\t", 
      RowBox[{"If", "[", 
       RowBox[{
        RowBox[{"n", "=!=", "All"}], ",", "n", ",", 
        RowBox[{"Sequence", "@@", 
         RowBox[{"{", "}"}]}]}], "]"}]}], "\n", "\t", "]"}]}]}]}]], "Input",
 GeneratedCell->True,
 CellAutoOverwrite->True,
 CellChangeTimes->{3.539876919401367*^9}],

Cell[BoxData[
 RowBox[{"prn", "@", 
  RowBox[{"FullCodeFormatCompact", "@", "boxes5"}]}]], "Input",
 CellChangeTimes->{{3.539877292236328*^9, 3.5398772934121094`*^9}, 
   3.540387641555618*^9}],

Cell[BoxData[
 RowBox[{"\n", 
  RowBox[{
   RowBox[{
    RowBox[{"Clear", "[", "getSamplesP", "]"}], ";"}], "\n", 
   RowBox[{
    RowBox[{"getSamplesP", "[", 
     RowBox[{"data_List", ",", 
      RowBox[{"minlen_Integer", "?", "Positive"}], ",", 
      RowBox[{"n", ":", 
       RowBox[{"_Integer", "|", "All"}], ":", "All"}]}], "]"}], ":=", "\n", 
    "\t", 
    RowBox[{"Select", "[", "\t", "\t", "\n", "\t", "\t", 
     RowBox[{
      RowBox[{
       RowBox[{"(", 
        RowBox[{
         RowBox[{"Transpose", "[", 
          RowBox[{"{", 
           RowBox[{"#1", ",", 
            RowBox[{"Range", "[", 
             RowBox[{"Length", "[", "#1", "]"}], "]"}]}], "}"}], "]"}], "&"}],
         ")"}], "[", 
       RowBox[{"Partition", "[", 
        RowBox[{"data", ",", "minlen", ",", "1"}], "]"}], "]"}], ",", "\n", 
      "\t", "\t", 
      RowBox[{
       RowBox[{"!", 
        RowBox[{"MemberQ", "[", 
         RowBox[{
          RowBox[{"First", "[", "#1", "]"}], ",", 
          RowBox[{"0", "|", "Null"}]}], "]"}]}], "&"}], ",", "\n", "\t", "\t", 
      RowBox[{"If", "[", 
       RowBox[{
        RowBox[{"n", "=!=", "All"}], ",", "n", ",", 
        RowBox[{"Sequence", "@@", 
         RowBox[{"{", "}"}]}]}], "]"}]}], "]"}]}]}]}]], "Input",
 GeneratedCell->True,
 CellAutoOverwrite->True,
 CellChangeTimes->{3.539877294091797*^9}]
}, Closed]],

Cell[CellGroupData[{

Cell["Example4", "Subsubsection",
 CellChangeTimes->{{3.5391590269228516`*^9, 3.5391590281289062`*^9}, 
   3.540401565240886*^9}],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"\[IndentingNewLine]", 
  RowBox[{"boxes4", "  ", "=", " ", "\[IndentingNewLine]", 
   RowBox[{"MakeBoxes", "[", "\[IndentingNewLine]", 
    RowBox[{
     RowBox[{"findLsts2", "[", 
      RowBox[{"lst_", ",", 
       RowBox[{"minLen_Integer", "?", "Positive"}], ",", "maxZeros_", ",", 
       RowBox[{"n", ":", 
        RowBox[{
         RowBox[{"(", 
          RowBox[{"_Integer", "|", "All"}], ")"}], ":", "All"}]}]}], "]"}], ":=", 
     RowBox[{"Module", "[", 
      RowBox[{
       RowBox[{"{", 
        RowBox[{"zeroLst", ",", "rangeLst"}], "}"}], ",", 
       RowBox[{
        RowBox[{"zeroLst", "=", 
         RowBox[{"Flatten", "[", 
          RowBox[{"Position", "[", 
           RowBox[{"lst", ",", 
            RowBox[{"(", 
             RowBox[{"0", "|", "0.", "|", "Null"}], ")"}]}], "]"}], "]"}]}], 
        ";", "\[IndentingNewLine]", 
        RowBox[{"If", "[", 
         RowBox[{
          RowBox[{
           RowBox[{"Length", "[", "zeroLst", "]"}], "\[LessEqual]", 
           "maxZeros"}], ",", "lst", ",", 
          RowBox[{
           RowBox[{"rangeLst", "=", 
            RowBox[{"Transpose", "[", 
             RowBox[{"{", 
              RowBox[{
               RowBox[{"Prepend", "[", 
                RowBox[{
                 RowBox[{"Drop", "[", 
                  RowBox[{
                   RowBox[{"zeroLst", "+", "1"}], ",", 
                   RowBox[{"-", "maxZeros"}]}], "]"}], ",", "1"}], "]"}], ",", 
               RowBox[{"Append", "[", 
                RowBox[{
                 RowBox[{"Drop", "[", 
                  RowBox[{
                   RowBox[{"zeroLst", "-", "1"}], ",", "maxZeros"}], "]"}], 
                 ",", 
                 RowBox[{"Length", "[", "lst", "]"}]}], "]"}]}], "}"}], 
             "]"}]}], ";", "\[IndentingNewLine]", 
           RowBox[{
            RowBox[{
             RowBox[{"{", 
              RowBox[{
               RowBox[{"Take", "[", 
                RowBox[{"lst", ",", "#"}], "]"}], ",", "#"}], "}"}], "&"}], "/@", 
            RowBox[{"Select", "[", 
             RowBox[{"rangeLst", ",", 
              RowBox[{
               RowBox[{
                RowBox[{"(", 
                 RowBox[{
                  RowBox[{"#", "[", 
                   RowBox[{"[", "2", "]"}], "]"}], "-", 
                  RowBox[{"#", "[", 
                   RowBox[{"[", "1", "]"}], "]"}], "+", "1"}], ")"}], 
                "\[GreaterEqual]", "minLen"}], "&"}], ",", 
              RowBox[{"n", "/.", 
               RowBox[{"All", "\[Rule]", 
                RowBox[{"Sequence", "[", "]"}]}]}]}], "]"}]}]}]}], "]"}]}]}], 
      "]"}]}], "]"}]}]}]], "Input",
 CellChangeTimes->{{3.5379946334356093`*^9, 3.5379946345899067`*^9}}],

Cell[BoxData[
 RowBox[{"RowBox", "[", 
  RowBox[{"{", 
   RowBox[{
    RowBox[{"RowBox", "[", 
     RowBox[{"{", 
      RowBox[{"\<\"findLsts2\"\>", ",", "\<\"[\"\>", ",", 
       RowBox[{"RowBox", "[", 
        RowBox[{"{", 
         RowBox[{"\<\"lst_\"\>", ",", "\<\",\"\>", ",", 
          RowBox[{"RowBox", "[", 
           RowBox[{"{", 
            
            RowBox[{"\<\"minLen_Integer\"\>", ",", "\<\"?\"\>", 
             ",", "\<\"Positive\"\>"}], "}"}], "]"}], ",", "\<\",\"\>", 
          ",", "\<\"maxZeros_\"\>", ",", "\<\",\"\>", ",", 
          RowBox[{"RowBox", "[", 
           RowBox[{"{", 
            RowBox[{"\<\"n\"\>", ",", "\<\":\"\>", ",", 
             RowBox[{"RowBox", "[", 
              RowBox[{"{", 
               
               RowBox[{"\<\"_Integer\"\>", ",", "\<\"|\"\>", 
                ",", "\<\"All\"\>"}], "}"}], "]"}], ",", "\<\":\"\>", 
             ",", "\<\"All\"\>"}], "}"}], "]"}]}], "}"}], "]"}], 
       ",", "\<\"]\"\>"}], "}"}], "]"}], ",", "\<\":=\"\>", ",", 
    RowBox[{"RowBox", "[", 
     RowBox[{"{", 
      RowBox[{"\<\"Module\"\>", ",", "\<\"[\"\>", ",", 
       RowBox[{"RowBox", "[", 
        RowBox[{"{", 
         RowBox[{
          RowBox[{"RowBox", "[", 
           RowBox[{"{", 
            RowBox[{"\<\"{\"\>", ",", 
             RowBox[{"RowBox", "[", 
              RowBox[{"{", 
               
               RowBox[{"\<\"zeroLst\"\>", ",", "\<\",\"\>", 
                ",", "\<\"rangeLst\"\>"}], "}"}], "]"}], ",", "\<\"}\"\>"}], 
            "}"}], "]"}], ",", "\<\",\"\>", ",", 
          RowBox[{"RowBox", "[", 
           RowBox[{"{", 
            RowBox[{
             RowBox[{"RowBox", "[", 
              RowBox[{"{", 
               RowBox[{"\<\"zeroLst\"\>", ",", "\<\"=\"\>", ",", 
                RowBox[{"RowBox", "[", 
                 RowBox[{"{", 
                  RowBox[{"\<\"Flatten\"\>", ",", "\<\"[\"\>", ",", 
                   RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"Position\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"lst\"\>", ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"0\"\>", ",", "\<\"|\"\>", ",", "\<\"0.`\"\>",
                     ",", "\<\"|\"\>", ",", "\<\"Null\"\>"}], "}"}], "]"}]}], 
                    "}"}], "]"}], ",", "\<\"]\"\>"}], "}"}], "]"}], 
                   ",", "\<\"]\"\>"}], "}"}], "]"}]}], "}"}], "]"}], 
             ",", "\<\";\"\>", ",", 
             RowBox[{"RowBox", "[", 
              RowBox[{"{", 
               RowBox[{"\<\"If\"\>", ",", "\<\"[\"\>", ",", 
                RowBox[{"RowBox", "[", 
                 RowBox[{"{", 
                  RowBox[{
                   RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"Length\"\>", ",", "\<\"[\"\>", 
                    ",", "\<\"zeroLst\"\>", ",", "\<\"]\"\>"}], "}"}], "]"}], 
                    ",", "\<\"\[LessEqual]\"\>", ",", "\<\"maxZeros\"\>"}], 
                    "}"}], "]"}], ",", "\<\",\"\>", ",", "\<\"lst\"\>", 
                   ",", "\<\",\"\>", ",", 
                   RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"rangeLst\"\>", ",", "\<\"=\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"Transpose\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"{\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"Prepend\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"Drop\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"zeroLst\"\>", ",", "\<\"+\"\>", 
                    ",", "\<\"1\"\>"}], "}"}], "]"}], ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"-\"\>", ",", "\<\"maxZeros\"\>"}], "}"}], 
                    "]"}]}], "}"}], "]"}], ",", "\<\"]\"\>"}], "}"}], "]"}], 
                    ",", "\<\",\"\>", ",", "\<\"1\"\>"}], "}"}], "]"}], 
                    ",", "\<\"]\"\>"}], "}"}], "]"}], ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"Append\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"Drop\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"zeroLst\"\>", ",", "\<\"-\"\>", 
                    ",", "\<\"1\"\>"}], "}"}], "]"}], ",", "\<\",\"\>", 
                    ",", "\<\"maxZeros\"\>"}], "}"}], "]"}], 
                    ",", "\<\"]\"\>"}], "}"}], "]"}], ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"Length\"\>", ",", "\<\"[\"\>", 
                    ",", "\<\"lst\"\>", ",", "\<\"]\"\>"}], "}"}], "]"}]}], 
                    "}"}], "]"}], ",", "\<\"]\"\>"}], "}"}], "]"}]}], "}"}], 
                    "]"}], ",", "\<\"}\"\>"}], "}"}], "]"}], 
                    ",", "\<\"]\"\>"}], "}"}], "]"}]}], "}"}], "]"}], 
                    ",", "\<\";\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"(\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"{\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"Take\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"lst\"\>", ",", "\<\",\"\>", 
                    ",", "\<\"#1\"\>"}], "}"}], "]"}], ",", "\<\"]\"\>"}], 
                    "}"}], "]"}], ",", "\<\",\"\>", ",", "\<\"#1\"\>"}], 
                    "}"}], "]"}], ",", "\<\"}\"\>"}], "}"}], "]"}], 
                    ",", "\<\"&\"\>"}], "}"}], "]"}], ",", "\<\")\"\>"}], 
                    "}"}], "]"}], ",", "\<\"/@\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"Select\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"rangeLst\"\>", ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"#1\"\>", ",", "\<\"\[LeftDoubleBracket]\"\>",
                     ",", "\<\"2\"\>", ",", "\<\"\[RightDoubleBracket]\"\>"}],
                     "}"}], "]"}], ",", "\<\"-\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"#1\"\>", ",", "\<\"\[LeftDoubleBracket]\"\>",
                     ",", "\<\"1\"\>", ",", "\<\"\[RightDoubleBracket]\"\>"}],
                     "}"}], "]"}], ",", "\<\"+\"\>", ",", "\<\"1\"\>"}], 
                    "}"}], "]"}], ",", "\<\"\[GreaterEqual]\"\>", 
                    ",", "\<\"minLen\"\>"}], "}"}], "]"}], ",", "\<\"&\"\>"}],
                     "}"}], "]"}], ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"n\"\>", ",", "\<\"/.\"\>", 
                    ",", "\<\"\[InvisibleSpace]\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"All\"\>", ",", "\<\"\[Rule]\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"Sequence\"\>", ",", "\<\"[\"\>", 
                    ",", "\<\"]\"\>"}], "}"}], "]"}]}], "}"}], "]"}]}], "}"}],
                     "]"}]}], "}"}], "]"}], ",", "\<\"]\"\>"}], "}"}], 
                    "]"}]}], "}"}], "]"}]}], "}"}], "]"}]}], "}"}], "]"}], 
                ",", "\<\"]\"\>"}], "}"}], "]"}]}], "}"}], "]"}]}], "}"}], 
        "]"}], ",", "\<\"]\"\>"}], "}"}], "]"}]}], "}"}], "]"}]], "Output",
 CellChangeTimes->{3.537994636858461*^9, 3.538036716746766*^9, 
  3.53874382271875*^9, 3.5387494833808594`*^9, 3.5391590868203125`*^9, 
  3.539184610048828*^9, 3.5398769645527344`*^9}]
}, Open  ]],

Cell[BoxData[
 RowBox[{
  RowBox[{"format", "@", 
   RowBox[{"preformat", "@", "boxes4"}]}], ";"}]], "Input",
 CellChangeTimes->{3.5391973501168594`*^9}],

Cell[BoxData[""], "Input",
 CellChangeTimes->{{3.5391969644957657`*^9, 3.5391969646676407`*^9}}],

Cell[BoxData[
 RowBox[{"prn", "@", 
  RowBox[{"FullCodeFormat", "@", "boxes4"}]}]], "Input",
 CellChangeTimes->{{3.5379946466074843`*^9, 3.537994646778383*^9}, 
   3.539876971236328*^9, 3.540387641598422*^9}],

Cell[BoxData[
 RowBox[{
  RowBox[{"findLsts2", "[", 
   RowBox[{"lst_", ",", 
    RowBox[{"minLen_Integer", "?", "Positive"}], ",", "maxZeros_", ",", 
    RowBox[{"n", ":", 
     RowBox[{"_Integer", "|", "All"}], ":", "All"}]}], "]"}], ":=", "\n", 
  "\t", 
  RowBox[{"Module", "[", 
   RowBox[{
    RowBox[{"{", 
     RowBox[{"zeroLst", ",", "rangeLst"}], "}"}], ",", "\t", "\t", "\n", "\t",
     "\t", 
    RowBox[{
     RowBox[{"zeroLst", "=", 
      RowBox[{"Flatten", "[", 
       RowBox[{"Position", "[", 
        RowBox[{"lst", ",", 
         RowBox[{"0", "|", "0.`", "|", "Null"}]}], "]"}], "]"}]}], ";", "\n", 
     "\t", "\t", 
     RowBox[{"If", "[", "\n", "\t", "\t", "\t", 
      RowBox[{
       RowBox[{
        RowBox[{"Length", "[", "zeroLst", "]"}], "\[LessEqual]", "maxZeros"}],
        ",", "\n", "\t", "\t", "\t", "lst", ",", "\n", "\t", "\t", "\t", 
       RowBox[{"(*", " ", "else", " ", "*)"}], "\t", "\t", "\t", "\n", "\t", 
       "\t", "\t", 
       RowBox[{
        RowBox[{"rangeLst", "=", "\n", "\t", "\t", "\t", "\t", 
         RowBox[{"Transpose", "[", "\n", "\t", "\t", "\t", "\t", "\t", 
          RowBox[{
          "{", "\t", "\t", "\t", "\t", "\t", "\t", "\n", "\t", "\t", "\t", 
           "\t", "\t", "\t", 
           RowBox[{
            RowBox[{"Prepend", "[", 
             RowBox[{
              RowBox[{"Drop", "[", 
               RowBox[{
                RowBox[{"zeroLst", "+", "1"}], ",", 
                RowBox[{"-", "maxZeros"}]}], "]"}], ",", "1"}], "]"}], ",", 
            "\n", "\t", "\t", "\t", "\t", "\t", "\t", 
            RowBox[{"Append", "[", 
             RowBox[{
              RowBox[{"Drop", "[", 
               RowBox[{
                RowBox[{"zeroLst", "-", "1"}], ",", "maxZeros"}], "]"}], ",", 
              
              RowBox[{"Length", "[", "lst", "]"}]}], "]"}]}], "\n", "\t", 
           "\t", "\t", "\t", "\t", "}"}], "\n", "\t", "\t", "\t", "\t", 
          "]"}]}], ";", "\n", "\t", "\t", "\t", 
        RowBox[{
         RowBox[{"(", 
          RowBox[{
           RowBox[{"{", 
            RowBox[{
             RowBox[{"Take", "[", 
              RowBox[{"lst", ",", "#1"}], "]"}], ",", "#1"}], "}"}], "&"}], 
          ")"}], "/@", "\n", "\t", "\t", "\t", "\t", 
         RowBox[{"Select", "[", "\n", "\t", "\t", "\t", "\t", "\t", 
          RowBox[{"rangeLst", ",", 
           RowBox[{
            RowBox[{
             RowBox[{
              RowBox[{
              "#1", "\[LeftDoubleBracket]", "2", "\[RightDoubleBracket]"}], 
              "-", 
              RowBox[{
              "#1", "\[LeftDoubleBracket]", "1", "\[RightDoubleBracket]"}], 
              "+", "1"}], "\[GreaterEqual]", "minLen"}], "&"}], ",", 
           RowBox[{"n", "/.", "\[InvisibleSpace]", 
            RowBox[{"All", "\[Rule]", 
             RowBox[{"Sequence", "[", "]"}]}]}]}], "\n", "\t", "\t", "\t", 
          "\t", "]"}]}]}]}], "\n", "\t", "\t", "]"}]}]}], "\n", "\t", 
   "]"}]}]], "Input",
 GeneratedCell->True,
 CellAutoOverwrite->True,
 CellChangeTimes->{3.5398769723779297`*^9}],

Cell[BoxData[
 RowBox[{"prn", "@", 
  RowBox[{"FullCodeFormatCompact", "@", "boxes4"}]}]], "Input",
 CellChangeTimes->{{3.539877307095703*^9, 3.5398773083242188`*^9}, 
   3.540387641641229*^9}],

Cell[BoxData[
 RowBox[{
  RowBox[{"findLsts2", "[", 
   RowBox[{"lst_", ",", 
    RowBox[{"minLen_Integer", "?", "Positive"}], ",", "maxZeros_", ",", 
    RowBox[{"n", ":", 
     RowBox[{"_Integer", "|", "All"}], ":", "All"}]}], "]"}], ":=", "\n", 
  "\t", 
  RowBox[{"Module", "[", 
   RowBox[{
    RowBox[{"{", 
     RowBox[{"zeroLst", ",", "rangeLst"}], "}"}], ",", "\t", "\t", "\n", "\t",
     "\t", 
    RowBox[{
     RowBox[{"zeroLst", "=", 
      RowBox[{"Flatten", "[", 
       RowBox[{"Position", "[", 
        RowBox[{"lst", ",", 
         RowBox[{"0", "|", "0.`", "|", "Null"}]}], "]"}], "]"}]}], ";", "\n", 
     "\t", "\t", 
     RowBox[{"If", "[", "\n", "\t", "\t", "\t", 
      RowBox[{
       RowBox[{
        RowBox[{"Length", "[", "zeroLst", "]"}], "\[LessEqual]", "maxZeros"}],
        ",", "\n", "\t", "\t", "\t", "lst", ",", "\n", "\t", "\t", "\t", 
       RowBox[{"(*", " ", "else", " ", "*)"}], "\t", "\t", "\t", "\n", "\t", 
       "\t", "\t", 
       RowBox[{
        RowBox[{"rangeLst", "=", "\n", "\t", "\t", "\t", "\t", 
         RowBox[{"Transpose", "[", "\n", "\t", "\t", "\t", "\t", "\t", 
          RowBox[{
          "{", "\t", "\t", "\t", "\t", "\t", "\t", "\n", "\t", "\t", "\t", 
           "\t", "\t", "\t", 
           RowBox[{
            RowBox[{"Prepend", "[", 
             RowBox[{
              RowBox[{"Drop", "[", 
               RowBox[{
                RowBox[{"zeroLst", "+", "1"}], ",", 
                RowBox[{"-", "maxZeros"}]}], "]"}], ",", "1"}], "]"}], ",", 
            "\n", "\t", "\t", "\t", "\t", "\t", "\t", 
            RowBox[{"Append", "[", 
             RowBox[{
              RowBox[{"Drop", "[", 
               RowBox[{
                RowBox[{"zeroLst", "-", "1"}], ",", "maxZeros"}], "]"}], ",", 
              
              RowBox[{"Length", "[", "lst", "]"}]}], "]"}]}], "}"}], "]"}]}], 
        ";", "\n", "\t", "\t", "\t", 
        RowBox[{
         RowBox[{"(", 
          RowBox[{
           RowBox[{"{", 
            RowBox[{
             RowBox[{"Take", "[", 
              RowBox[{"lst", ",", "#1"}], "]"}], ",", "#1"}], "}"}], "&"}], 
          ")"}], "/@", "\n", "\t", "\t", "\t", "\t", 
         RowBox[{"Select", "[", "\n", "\t", "\t", "\t", "\t", "\t", 
          RowBox[{"rangeLst", ",", 
           RowBox[{
            RowBox[{
             RowBox[{
              RowBox[{
              "#1", "\[LeftDoubleBracket]", "2", "\[RightDoubleBracket]"}], 
              "-", 
              RowBox[{
              "#1", "\[LeftDoubleBracket]", "1", "\[RightDoubleBracket]"}], 
              "+", "1"}], "\[GreaterEqual]", "minLen"}], "&"}], ",", 
           RowBox[{"n", "/.", "\[InvisibleSpace]", 
            RowBox[{"All", "\[Rule]", 
             RowBox[{"Sequence", "[", "]"}]}]}]}], "]"}]}]}]}], "]"}]}]}], 
   "]"}]}]], "Input",
 GeneratedCell->True,
 CellAutoOverwrite->True,
 CellChangeTimes->{3.5398773090654297`*^9}]
}, Closed]],

Cell[CellGroupData[{

Cell["Example5", "Subsubsection",
 CellChangeTimes->{{3.539159118397461*^9, 3.539159119154297*^9}, 
   3.540401566023257*^9}],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"boxes3", " ", "=", " ", "\[IndentingNewLine]", 
  RowBox[{"MakeBoxes", "[", 
   RowBox[{
    RowBox[{"Clear", "[", "maxLen", "]"}], ";", "\[IndentingNewLine]", 
    RowBox[{
     RowBox[{"maxLen", "[", "boxes_", "]"}], ":=", "\[IndentingNewLine]", 
     RowBox[{"Max", "@", 
      RowBox[{"Total", "[", "\[IndentingNewLine]", 
       RowBox[{
        RowBox[{"Split", "[", "\[IndentingNewLine]", 
         RowBox[{
          RowBox[{"Cases", "[", 
           RowBox[{"boxes", ",", "\[IndentingNewLine]", 
            RowBox[{"s_String", "\[RuleDelayed]", 
             RowBox[{"(", 
              RowBox[{"s", "/.", 
               RowBox[{"{", 
                RowBox[{
                 RowBox[{"\"\<\\t\>\"", "->", "4"}], ",", 
                 RowBox[{"\"\<\\n\>\"", "\[RuleDelayed]", "0"}], ",", 
                 RowBox[{"ss_", "\[RuleDelayed]", 
                  RowBox[{"StringLength", "[", "ss", "]"}]}]}], "}"}]}], 
              ")"}]}], ",", "\[IndentingNewLine]", "Infinity"}], "]"}], ",", 
          "\[IndentingNewLine]", 
          RowBox[{
           RowBox[{"#", "=!=", "0"}], "&"}]}], "]"}], ",", 
        RowBox[{"{", "2", "}"}]}], "]"}]}]}]}], "]"}]}]], "Input"],

Cell[BoxData[
 RowBox[{"RowBox", "[", 
  RowBox[{"{", 
   RowBox[{
    RowBox[{"RowBox", "[", 
     RowBox[{"{", 
      RowBox[{"\<\"Clear\"\>", ",", "\<\"[\"\>", ",", "\<\"maxLen\"\>", 
       ",", "\<\"]\"\>"}], "}"}], "]"}], ",", "\<\";\"\>", ",", 
    RowBox[{"RowBox", "[", 
     RowBox[{"{", 
      RowBox[{
       RowBox[{"RowBox", "[", 
        RowBox[{"{", 
         RowBox[{"\<\"maxLen\"\>", ",", "\<\"[\"\>", ",", "\<\"boxes_\"\>", 
          ",", "\<\"]\"\>"}], "}"}], "]"}], ",", "\<\":=\"\>", ",", 
       RowBox[{"RowBox", "[", 
        RowBox[{"{", 
         RowBox[{"\<\"Max\"\>", ",", "\<\"[\"\>", ",", 
          RowBox[{"RowBox", "[", 
           RowBox[{"{", 
            RowBox[{"\<\"Total\"\>", ",", "\<\"[\"\>", ",", 
             RowBox[{"RowBox", "[", 
              RowBox[{"{", 
               RowBox[{
                RowBox[{"RowBox", "[", 
                 RowBox[{"{", 
                  RowBox[{"\<\"Split\"\>", ",", "\<\"[\"\>", ",", 
                   RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"Cases\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"boxes\"\>", ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"s_String\"\>", ",", "\<\"\[RuleDelayed]\"\>",
                     ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"(\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"s\"\>", ",", "\<\"/.\"\>", 
                    ",", "\<\"\[VeryThinSpace]\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"{\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"\\\"\\\\t\\\"\"\>", ",", "\<\"\[Rule]\"\>", 
                    ",", "\<\"4\"\>"}], "}"}], "]"}], ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"\\\"\\\\n\\\"\"\>", 
                    ",", "\<\"\[RuleDelayed]\"\>", ",", "\<\"0\"\>"}], "}"}], 
                    "]"}], ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"ss_\"\>", ",", "\<\"\[RuleDelayed]\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"StringLength\"\>", ",", "\<\"[\"\>", 
                    ",", "\<\"ss\"\>", ",", "\<\"]\"\>"}], "}"}], "]"}]}], 
                    "}"}], "]"}]}], "}"}], "]"}], ",", "\<\"}\"\>"}], "}"}], 
                    "]"}]}], "}"}], "]"}], ",", "\<\")\"\>"}], "}"}], "]"}]}],
                     "}"}], "]"}], ",", "\<\",\"\>", 
                    ",", "\<\"\[Infinity]\"\>"}], "}"}], "]"}], 
                    ",", "\<\"]\"\>"}], "}"}], "]"}], ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"#1\"\>", ",", "\<\"=!=\"\>", 
                    ",", "\<\"0\"\>"}], "}"}], "]"}], ",", "\<\"&\"\>"}], 
                    "}"}], "]"}]}], "}"}], "]"}], ",", "\<\"]\"\>"}], "}"}], 
                 "]"}], ",", "\<\",\"\>", ",", 
                RowBox[{"RowBox", "[", 
                 RowBox[{"{", 
                  RowBox[{"\<\"{\"\>", ",", "\<\"2\"\>", ",", "\<\"}\"\>"}], 
                  "}"}], "]"}]}], "}"}], "]"}], ",", "\<\"]\"\>"}], "}"}], 
           "]"}], ",", "\<\"]\"\>"}], "}"}], "]"}]}], "}"}], "]"}]}], "}"}], 
  "]"}]], "Output",
 CellChangeTimes->{3.537994840295961*^9, 3.5387495154003906`*^9, 
  3.5391591382910156`*^9, 3.5391878947128906`*^9, 3.5398770142666016`*^9, 
  3.540401748653556*^9}]
}, Open  ]],

Cell[BoxData[
 RowBox[{"prn", "@", 
  RowBox[{"FullCodeFormat", "@", "boxes3"}]}]], "Input",
 CellChangeTimes->{{3.537994851579164*^9, 3.5379948516924458`*^9}, 
   3.5398770192978516`*^9, 3.540387641684276*^9}],

Cell[BoxData[
 RowBox[{"\n", 
  RowBox[{
   RowBox[{
    RowBox[{"Clear", "[", "maxLen", "]"}], ";"}], "\n", 
   RowBox[{
    RowBox[{"maxLen", "[", "boxes_", "]"}], ":=", "\n", "\t", 
    RowBox[{"Max", "[", "\n", "\t", "\t", 
     RowBox[{"Total", "[", "\t", "\t", "\t", "\n", "\t", "\t", "\t", 
      RowBox[{
       RowBox[{
       "Split", "[", "\t", "\t", "\t", "\t", "\n", "\t", "\t", "\t", "\t", 
        RowBox[{
         RowBox[{
         "Cases", "[", "\t", "\t", "\t", "\t", "\t", "\n", "\t", "\t", "\t", 
          "\t", "\t", 
          RowBox[{"boxes", ",", "\n", "\t", "\t", "\t", "\t", "\t", 
           RowBox[{
           "s_String", "\[RuleDelayed]", "\n", "\t", "\t", "\t", "\t", "\t", 
            "\t", 
            RowBox[{"(", 
             RowBox[{"s", "/.", "\[VeryThinSpace]", 
              RowBox[{"{", 
               RowBox[{
                RowBox[{"\"\<\\t\>\"", "\[Rule]", "4"}], ",", 
                RowBox[{"\"\<\\n\>\"", "\[RuleDelayed]", "0"}], ",", 
                RowBox[{"ss_", "\[RuleDelayed]", 
                 RowBox[{"StringLength", "[", "ss", "]"}]}]}], "}"}]}], 
             ")"}]}], ",", "\n", "\t", "\t", "\t", "\t", "\t", 
           "\[Infinity]"}], "\n", "\t", "\t", "\t", "\t", "]"}], ",", "\n", 
         "\t", "\t", "\t", "\t", 
         RowBox[{
          RowBox[{"#1", "=!=", "0"}], "&"}]}], "\n", "\t", "\t", "\t", "]"}], 
       ",", "\n", "\t", "\t", "\t", 
       RowBox[{"{", "2", "}"}]}], "\n", "\t", "\t", "]"}], "\n", "\t", 
     "]"}]}]}]}]], "Input",
 GeneratedCell->True,
 CellAutoOverwrite->True,
 CellChangeTimes->{3.540401749796222*^9}],

Cell[BoxData[
 RowBox[{"prn", "@", 
  RowBox[{"FullCodeFormatCompact", "@", "boxes3"}]}]], "Input",
 CellChangeTimes->{{3.5398773299970703`*^9, 3.5398773312001953`*^9}, 
   3.540387641726947*^9}],

Cell[BoxData[
 RowBox[{"\n", 
  RowBox[{
   RowBox[{
    RowBox[{"Clear", "[", "maxLen", "]"}], ";"}], "\n", 
   RowBox[{
    RowBox[{"maxLen", "[", "boxes_", "]"}], ":=", "\n", "\t", 
    RowBox[{"Max", "[", "\n", "\t", "\t", 
     RowBox[{"Total", "[", "\t", "\t", "\t", "\n", "\t", "\t", "\t", 
      RowBox[{
       RowBox[{
       "Split", "[", "\t", "\t", "\t", "\t", "\n", "\t", "\t", "\t", "\t", 
        RowBox[{
         RowBox[{
         "Cases", "[", "\t", "\t", "\t", "\t", "\t", "\n", "\t", "\t", "\t", 
          "\t", "\t", 
          RowBox[{"boxes", ",", "\n", "\t", "\t", "\t", "\t", "\t", 
           RowBox[{
           "s_String", "\[RuleDelayed]", "\n", "\t", "\t", "\t", "\t", "\t", 
            "\t", 
            RowBox[{"(", 
             RowBox[{"s", "/.", "\[InvisibleSpace]", 
              RowBox[{"{", 
               RowBox[{
                RowBox[{"\"\<\\t\>\"", "\[Rule]", "4"}], ",", 
                RowBox[{"\"\<\\n\>\"", "\[RuleDelayed]", "0"}], ",", 
                RowBox[{"ss_", "\[RuleDelayed]", 
                 RowBox[{"StringLength", "[", "ss", "]"}]}]}], "}"}]}], 
             ")"}]}], ",", "\n", "\t", "\t", "\t", "\t", "\t", 
           "\[Infinity]"}], "]"}], ",", "\n", "\t", "\t", "\t", "\t", 
         RowBox[{
          RowBox[{"#1", "=!=", "0"}], "&"}]}], "]"}], ",", "\n", "\t", "\t", 
       "\t", 
       RowBox[{"{", "2", "}"}]}], "]"}], "]"}]}]}]}]], "Input",
 GeneratedCell->True,
 CellAutoOverwrite->True,
 CellChangeTimes->{3.539877331810547*^9}]
}, Closed]],

Cell[CellGroupData[{

Cell["Example6", "Subsubsection",
 CellChangeTimes->{{3.539159154192383*^9, 3.5391591550751953`*^9}, 
   3.540401566654604*^9}],

Cell[BoxData[
 RowBox[{"(*", "\[IndentingNewLine]", 
  RowBox[{"prn", "@", 
   RowBox[{"FullCodeFormat", "@", 
    RowBox[{"MakeBoxes", "[", 
     RowBox[{
      RowBox[{"SetAttributes", "[", 
       RowBox[{"CleanUp", ",", "HoldAll"}], "]"}], ";", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"CleanUp", "[", 
        RowBox[{"expr_", ",", "cleanup_"}], "]"}], ":=", 
       RowBox[{"Module", "[", 
        RowBox[{
         RowBox[{"{", 
          RowBox[{"exprFn", ",", "result", ",", 
           RowBox[{"abort", "=", "False"}], ",", 
           RowBox[{"rethrow", "=", "True"}], ",", "seq"}], "}"}], ",", 
         RowBox[{
          RowBox[{
           RowBox[{"exprFn", "[", "]"}], ":=", "expr"}], ";", 
          RowBox[{"result", "=", 
           RowBox[{"CheckAbort", "[", 
            RowBox[{
             RowBox[{"Catch", "[", 
              RowBox[{
               RowBox[{"Catch", "[", 
                RowBox[{
                 RowBox[{"result", "=", 
                  RowBox[{"exprFn", "[", "]"}]}], ";", 
                 RowBox[{"rethrow", "=", "False"}], ";", "result"}], "]"}], 
               ",", "_", ",", 
               RowBox[{
                RowBox[{"seq", "[", "##1", "]"}], "&"}]}], "]"}], ",", 
             RowBox[{"abort", "=", "True"}]}], "]"}]}], ";", "cleanup", ";", 
          RowBox[{"If", "[", 
           RowBox[{"abort", ",", 
            RowBox[{"Abort", "[", "]"}]}], "]"}], ";", 
          RowBox[{"If", "[", 
           RowBox[{"rethrow", ",", 
            RowBox[{"Throw", "[", 
             RowBox[{"result", "/.", 
              RowBox[{"seq", "\[Rule]", "Sequence"}]}], "]"}]}], "]"}], ";", 
          "result"}]}], "]"}]}]}], "]"}]}]}], "\[IndentingNewLine]", 
  "*)"}]], "Input",
 CellChangeTimes->{{3.540396896060979*^9, 3.540396925984738*^9}}],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"boxes2", " ", "=", " ", "\[IndentingNewLine]", 
  RowBox[{"MakeBoxes", "[", 
   RowBox[{
    RowBox[{"SetAttributes", "[", 
     RowBox[{"CleanUp", ",", "HoldAll"}], "]"}], ";", 
    RowBox[{
     RowBox[{"CleanUp", "[", 
      RowBox[{"expr_", ",", "cleanup_"}], "]"}], ":=", 
     RowBox[{"Module", "[", 
      RowBox[{
       RowBox[{"{", 
        RowBox[{"exprFn", ",", "result", ",", 
         RowBox[{"abort", "=", "False"}], ",", 
         RowBox[{"rethrow", "=", "True"}], ",", "seq"}], "}"}], ",", 
       RowBox[{
        RowBox[{
         RowBox[{"exprFn", "[", "]"}], ":=", "expr"}], ";", 
        RowBox[{"result", "=", 
         RowBox[{"CheckAbort", "[", 
          RowBox[{
           RowBox[{"Catch", "[", 
            RowBox[{
             RowBox[{"Catch", "[", 
              RowBox[{
               RowBox[{"result", "=", 
                RowBox[{"exprFn", "[", "]"}]}], ";", 
               RowBox[{"rethrow", "=", "False"}], ";", "result"}], "]"}], ",",
              "_", ",", 
             RowBox[{
              RowBox[{"seq", "[", "##1", "]"}], "&"}]}], "]"}], ",", 
           RowBox[{"abort", "=", "True"}]}], "]"}]}], ";", "cleanup", ";", 
        RowBox[{"If", "[", 
         RowBox[{"abort", ",", 
          RowBox[{"Abort", "[", "]"}]}], "]"}], ";", 
        RowBox[{"If", "[", 
         RowBox[{"rethrow", ",", 
          RowBox[{"Throw", "[", 
           RowBox[{"result", "/.", "\[InvisibleSpace]", 
            RowBox[{"seq", "\[Rule]", "Sequence"}]}], "]"}]}], "]"}], ";", 
        "result"}]}], "]"}]}]}], "]"}]}]], "Input"],

Cell[BoxData[
 RowBox[{"RowBox", "[", 
  RowBox[{"{", 
   RowBox[{
    RowBox[{"RowBox", "[", 
     RowBox[{"{", 
      RowBox[{"\<\"SetAttributes\"\>", ",", "\<\"[\"\>", ",", 
       RowBox[{"RowBox", "[", 
        RowBox[{"{", 
         RowBox[{"\<\"CleanUp\"\>", ",", "\<\",\"\>", 
          ",", "\<\"HoldAll\"\>"}], "}"}], "]"}], ",", "\<\"]\"\>"}], "}"}], 
     "]"}], ",", "\<\";\"\>", ",", 
    RowBox[{"RowBox", "[", 
     RowBox[{"{", 
      RowBox[{
       RowBox[{"RowBox", "[", 
        RowBox[{"{", 
         RowBox[{"\<\"CleanUp\"\>", ",", "\<\"[\"\>", ",", 
          RowBox[{"RowBox", "[", 
           RowBox[{"{", 
            
            RowBox[{"\<\"expr_\"\>", ",", "\<\",\"\>", 
             ",", "\<\"cleanup_\"\>"}], "}"}], "]"}], ",", "\<\"]\"\>"}], 
         "}"}], "]"}], ",", "\<\":=\"\>", ",", 
       RowBox[{"RowBox", "[", 
        RowBox[{"{", 
         RowBox[{"\<\"Module\"\>", ",", "\<\"[\"\>", ",", 
          RowBox[{"RowBox", "[", 
           RowBox[{"{", 
            RowBox[{
             RowBox[{"RowBox", "[", 
              RowBox[{"{", 
               RowBox[{"\<\"{\"\>", ",", 
                RowBox[{"RowBox", "[", 
                 RowBox[{"{", 
                  
                  RowBox[{"\<\"exprFn\"\>", ",", "\<\",\"\>", 
                   ",", "\<\"result\"\>", ",", "\<\",\"\>", ",", 
                   RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"abort\"\>", ",", "\<\"=\"\>", 
                    ",", "\<\"False\"\>"}], "}"}], "]"}], ",", "\<\",\"\>", 
                   ",", 
                   RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"rethrow\"\>", ",", "\<\"=\"\>", 
                    ",", "\<\"True\"\>"}], "}"}], "]"}], ",", "\<\",\"\>", 
                   ",", "\<\"seq\"\>"}], "}"}], "]"}], ",", "\<\"}\"\>"}], 
               "}"}], "]"}], ",", "\<\",\"\>", ",", 
             RowBox[{"RowBox", "[", 
              RowBox[{"{", 
               RowBox[{
                RowBox[{"RowBox", "[", 
                 RowBox[{"{", 
                  RowBox[{
                   RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"exprFn\"\>", ",", "\<\"[\"\>", 
                    ",", "\<\"]\"\>"}], "}"}], "]"}], ",", "\<\":=\"\>", 
                   ",", "\<\"expr\"\>"}], "}"}], "]"}], ",", "\<\";\"\>", ",", 
                RowBox[{"RowBox", "[", 
                 RowBox[{"{", 
                  RowBox[{"\<\"result\"\>", ",", "\<\"=\"\>", ",", 
                   RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"CheckAbort\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"Catch\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"Catch\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"result\"\>", ",", "\<\"=\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"exprFn\"\>", ",", "\<\"[\"\>", 
                    ",", "\<\"]\"\>"}], "}"}], "]"}]}], "}"}], "]"}], 
                    ",", "\<\";\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"rethrow\"\>", ",", "\<\"=\"\>", 
                    ",", "\<\"False\"\>"}], "}"}], "]"}], ",", "\<\";\"\>", 
                    ",", "\<\"result\"\>"}], "}"}], "]"}], ",", "\<\"]\"\>"}],
                     "}"}], "]"}], ",", "\<\",\"\>", ",", "\<\"_\"\>", 
                    ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"seq\"\>", ",", "\<\"[\"\>", 
                    ",", "\<\"##1\"\>", ",", "\<\"]\"\>"}], "}"}], "]"}], 
                    ",", "\<\"&\"\>"}], "}"}], "]"}]}], "}"}], "]"}], 
                    ",", "\<\"]\"\>"}], "}"}], "]"}], ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"abort\"\>", ",", "\<\"=\"\>", 
                    ",", "\<\"True\"\>"}], "}"}], "]"}]}], "}"}], "]"}], 
                    ",", "\<\"]\"\>"}], "}"}], "]"}]}], "}"}], "]"}], 
                ",", "\<\";\"\>", ",", "\<\"cleanup\"\>", ",", "\<\";\"\>", 
                ",", 
                RowBox[{"RowBox", "[", 
                 RowBox[{"{", 
                  RowBox[{"\<\"If\"\>", ",", "\<\"[\"\>", ",", 
                   RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"abort\"\>", ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"Abort\"\>", ",", "\<\"[\"\>", 
                    ",", "\<\"]\"\>"}], "}"}], "]"}]}], "}"}], "]"}], 
                   ",", "\<\"]\"\>"}], "}"}], "]"}], ",", "\<\";\"\>", ",", 
                RowBox[{"RowBox", "[", 
                 RowBox[{"{", 
                  RowBox[{"\<\"If\"\>", ",", "\<\"[\"\>", ",", 
                   RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"rethrow\"\>", ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"Throw\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"result\"\>", ",", "\<\"/.\"\>", 
                    ",", "\<\"\[InvisibleSpace]\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"seq\"\>", ",", "\<\"\[Rule]\"\>", 
                    ",", "\<\"Sequence\"\>"}], "}"}], "]"}]}], "}"}], "]"}], 
                    ",", "\<\"]\"\>"}], "}"}], "]"}]}], "}"}], "]"}], 
                   ",", "\<\"]\"\>"}], "}"}], "]"}], ",", "\<\";\"\>", 
                ",", "\<\"result\"\>"}], "}"}], "]"}]}], "}"}], "]"}], 
          ",", "\<\"]\"\>"}], "}"}], "]"}]}], "}"}], "]"}]}], "}"}], 
  "]"}]], "Output",
 CellChangeTimes->{3.5379949530352187`*^9, 3.5387495280566406`*^9, 
  3.539159165388672*^9, 3.539198592041664*^9, 3.5398773494902344`*^9}]
}, Open  ]],

Cell[BoxData[
 RowBox[{"prn", "@", 
  RowBox[{"FullCodeFormat", "@", "boxes2"}]}]], "Input",
 CellChangeTimes->{{3.5379949606338515`*^9, 3.537994960757875*^9}, {
   3.539877354588867*^9, 3.539877360645508*^9}, 3.540387641769716*^9}],

Cell[BoxData[
 RowBox[{"\n", 
  RowBox[{
   RowBox[{
    RowBox[{"SetAttributes", "[", 
     RowBox[{"CleanUp", ",", "HoldAll"}], "]"}], ";"}], "\n", 
   RowBox[{
    RowBox[{"CleanUp", "[", 
     RowBox[{"expr_", ",", "cleanup_"}], "]"}], ":=", "\n", "\t", 
    RowBox[{"Module", "[", 
     RowBox[{
      RowBox[{"{", 
       RowBox[{"exprFn", ",", "result", ",", 
        RowBox[{"abort", "=", "False"}], ",", 
        RowBox[{"rethrow", "=", "True"}], ",", "seq"}], "}"}], ",", "\t", 
      "\t", "\n", "\t", "\t", 
      RowBox[{
       RowBox[{
        RowBox[{"exprFn", "[", "]"}], ":=", "\n", "\t", "\t", "\t", "expr"}], 
       ";", "\n", "\t", "\t", 
       RowBox[{"result", "=", "\n", "\t", "\t", "\t", 
        RowBox[{
        "CheckAbort", "[", "\t", "\t", "\t", "\t", "\n", "\t", "\t", "\t", 
         "\t", 
         RowBox[{
          RowBox[{
          "Catch", "[", "\t", "\t", "\t", "\t", "\t", "\n", "\t", "\t", "\t", 
           "\t", "\t", 
           RowBox[{
            RowBox[{"Catch", "[", 
             RowBox[{
              RowBox[{"result", "=", 
               RowBox[{"exprFn", "[", "]"}]}], ";", 
              RowBox[{"rethrow", "=", "False"}], ";", "result"}], "]"}], ",", 
            "\n", "\t", "\t", "\t", "\t", "\t", "_", ",", "\n", "\t", "\t", 
            "\t", "\t", "\t", 
            RowBox[{
             RowBox[{"seq", "[", "##1", "]"}], "&"}]}], "\n", "\t", "\t", 
           "\t", "\t", "]"}], ",", "\n", "\t", "\t", "\t", "\t", 
          RowBox[{"abort", "=", "True"}]}], "\n", "\t", "\t", "\t", "]"}]}], 
       ";", "\n", "\t", "\t", "cleanup", ";", "\n", "\t", "\t", 
       RowBox[{"If", "[", 
        RowBox[{"abort", ",", 
         RowBox[{"Abort", "[", "]"}]}], "]"}], ";", "\n", "\t", "\t", 
       RowBox[{"If", "[", 
        RowBox[{"rethrow", ",", 
         RowBox[{"Throw", "[", 
          RowBox[{"result", "/.", "\[InvisibleSpace]", 
           RowBox[{"seq", "\[Rule]", "Sequence"}]}], "]"}]}], "]"}], ";", 
       "\n", "\t", "\t", "result"}]}], "\n", "\t", "]"}]}]}]}]], "Input",
 GeneratedCell->True,
 CellAutoOverwrite->True,
 CellChangeTimes->{3.5398773704003906`*^9}],

Cell[BoxData[
 RowBox[{"prn", "@", 
  RowBox[{"FullCodeFormatCompact", "@", "boxes2"}]}]], "Input",
 CellChangeTimes->{{3.5398773825722656`*^9, 3.539877383732422*^9}, 
   3.540387641811932*^9}],

Cell[BoxData[
 RowBox[{"\n", 
  RowBox[{
   RowBox[{
    RowBox[{"SetAttributes", "[", 
     RowBox[{"CleanUp", ",", "HoldAll"}], "]"}], ";"}], "\n", 
   RowBox[{
    RowBox[{"CleanUp", "[", 
     RowBox[{"expr_", ",", "cleanup_"}], "]"}], ":=", "\n", "\t", 
    RowBox[{"Module", "[", 
     RowBox[{
      RowBox[{"{", 
       RowBox[{"exprFn", ",", "result", ",", 
        RowBox[{"abort", "=", "False"}], ",", 
        RowBox[{"rethrow", "=", "True"}], ",", "seq"}], "}"}], ",", "\t", 
      "\t", "\n", "\t", "\t", 
      RowBox[{
       RowBox[{
        RowBox[{"exprFn", "[", "]"}], ":=", "\n", "\t", "\t", "\t", "expr"}], 
       ";", "\n", "\t", "\t", 
       RowBox[{"result", "=", "\n", "\t", "\t", "\t", 
        RowBox[{
        "CheckAbort", "[", "\t", "\t", "\t", "\t", "\n", "\t", "\t", "\t", 
         "\t", 
         RowBox[{
          RowBox[{
          "Catch", "[", "\t", "\t", "\t", "\t", "\t", "\n", "\t", "\t", "\t", 
           "\t", "\t", 
           RowBox[{
            RowBox[{"Catch", "[", 
             RowBox[{
              RowBox[{"result", "=", 
               RowBox[{"exprFn", "[", "]"}]}], ";", 
              RowBox[{"rethrow", "=", "False"}], ";", "result"}], "]"}], ",", 
            "\n", "\t", "\t", "\t", "\t", "\t", "_", ",", "\n", "\t", "\t", 
            "\t", "\t", "\t", 
            RowBox[{
             RowBox[{"seq", "[", "##1", "]"}], "&"}]}], "]"}], ",", "\n", 
          "\t", "\t", "\t", "\t", 
          RowBox[{"abort", "=", "True"}]}], "]"}]}], ";", "\n", "\t", "\t", 
       "cleanup", ";", "\n", "\t", "\t", 
       RowBox[{"If", "[", 
        RowBox[{"abort", ",", 
         RowBox[{"Abort", "[", "]"}]}], "]"}], ";", "\n", "\t", "\t", 
       RowBox[{"If", "[", 
        RowBox[{"rethrow", ",", 
         RowBox[{"Throw", "[", 
          RowBox[{"result", "/.", "\[InvisibleSpace]", 
           RowBox[{"seq", "\[Rule]", "Sequence"}]}], "]"}]}], "]"}], ";", 
       "\n", "\t", "\t", "result"}]}], "]"}]}]}]}]], "Input",
 GeneratedCell->True,
 CellAutoOverwrite->True,
 CellChangeTimes->{3.5398773844414062`*^9}]
}, Closed]],

Cell[CellGroupData[{

Cell["Example7", "Subsubsection",
 CellChangeTimes->{{3.539159194254883*^9, 3.5391591951679688`*^9}, 
   3.540401567380342*^9}],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"testBoxes", " ", "=", " ", 
  RowBox[{"MakeBoxes", "@", "\[IndentingNewLine]", 
   RowBox[{"Module", "[", 
    RowBox[{
     RowBox[{"{", 
      RowBox[{"a", ",", "b"}], "}"}], ",", 
     RowBox[{
      RowBox[{"a", "=", "1"}], ";", 
      RowBox[{"Block", "[", 
       RowBox[{
        RowBox[{"{", 
         RowBox[{"c", ",", "d"}], "}"}], ",", 
        RowBox[{
         RowBox[{"c", "=", 
          RowBox[{"a", "+", "1"}]}], ";", 
         RowBox[{"d", "=", 
          RowBox[{"b", "+", "2"}]}]}]}], "]"}], ";", "b"}]}], 
    "]"}]}]}]], "Input",
 CellChangeTimes->{{3.5398774636591797`*^9, 3.539877468645508*^9}}],

Cell[BoxData[
 RowBox[{"RowBox", "[", 
  RowBox[{"{", 
   RowBox[{"\<\"Module\"\>", ",", "\<\"[\"\>", ",", 
    RowBox[{"RowBox", "[", 
     RowBox[{"{", 
      RowBox[{
       RowBox[{"RowBox", "[", 
        RowBox[{"{", 
         RowBox[{"\<\"{\"\>", ",", 
          RowBox[{"RowBox", "[", 
           RowBox[{"{", 
            RowBox[{"\<\"a\"\>", ",", "\<\",\"\>", ",", "\<\"b\"\>"}], "}"}], 
           "]"}], ",", "\<\"}\"\>"}], "}"}], "]"}], ",", "\<\",\"\>", ",", 
       RowBox[{"RowBox", "[", 
        RowBox[{"{", 
         RowBox[{
          RowBox[{"RowBox", "[", 
           RowBox[{"{", 
            RowBox[{"\<\"a\"\>", ",", "\<\"=\"\>", ",", "\<\"1\"\>"}], "}"}], 
           "]"}], ",", "\<\";\"\>", ",", 
          RowBox[{"RowBox", "[", 
           RowBox[{"{", 
            RowBox[{"\<\"Block\"\>", ",", "\<\"[\"\>", ",", 
             RowBox[{"RowBox", "[", 
              RowBox[{"{", 
               RowBox[{
                RowBox[{"RowBox", "[", 
                 RowBox[{"{", 
                  RowBox[{"\<\"{\"\>", ",", 
                   RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"c\"\>", ",", "\<\",\"\>", ",", "\<\"d\"\>"}],
                     "}"}], "]"}], ",", "\<\"}\"\>"}], "}"}], "]"}], 
                ",", "\<\",\"\>", ",", 
                RowBox[{"RowBox", "[", 
                 RowBox[{"{", 
                  RowBox[{
                   RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"c\"\>", ",", "\<\"=\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"a\"\>", ",", "\<\"+\"\>", ",", "\<\"1\"\>"}],
                     "}"}], "]"}]}], "}"}], "]"}], ",", "\<\";\"\>", ",", 
                   RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"d\"\>", ",", "\<\"=\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"b\"\>", ",", "\<\"+\"\>", ",", "\<\"2\"\>"}],
                     "}"}], "]"}]}], "}"}], "]"}]}], "}"}], "]"}]}], "}"}], 
              "]"}], ",", "\<\"]\"\>"}], "}"}], "]"}], ",", "\<\";\"\>", 
          ",", "\<\"b\"\>"}], "}"}], "]"}]}], "}"}], "]"}], 
    ",", "\<\"]\"\>"}], "}"}], "]"}]], "Output",
 CellChangeTimes->{3.537995051552797*^9, 3.538749543763672*^9, 
  3.539159201376953*^9, 3.53987740371875*^9, 3.539877469296875*^9}]
}, Open  ]],

Cell[BoxData[
 RowBox[{"prn", "@", 
  RowBox[{"FullCodeFormat", "@", "testBoxes"}]}]], "Input",
 CellChangeTimes->{
  3.537995063959047*^9, {3.5398774149160156`*^9, 3.539877416786133*^9}, 
   3.540387641866953*^9}],

Cell[BoxData[
 RowBox[{"Module", "[", 
  RowBox[{
   RowBox[{"{", 
    RowBox[{"a", ",", "b"}], "}"}], ",", "\t", "\n", "\t", 
   RowBox[{
    RowBox[{"a", "=", "1"}], ";", "\t", "\n", "\t", 
    RowBox[{"Block", "[", 
     RowBox[{
      RowBox[{"{", 
       RowBox[{"c", ",", "d"}], "}"}], ",", "\n", "\t", "\t", 
      RowBox[{
       RowBox[{"c", "=", 
        RowBox[{"a", "+", "1"}]}], ";", 
       RowBox[{"d", "=", 
        RowBox[{"b", "+", "2"}]}]}]}], "\n", "\t", "]"}], ";", "\n", "\t", 
    "b"}]}], "\n", "]"}]], "Input",
 GeneratedCell->True,
 CellAutoOverwrite->True,
 CellChangeTimes->{3.5398774711435547`*^9}],

Cell[BoxData[
 RowBox[{"prn", "@", 
  RowBox[{"FullCodeFormatCompact", "@", "testBoxes"}]}]], "Input",
 CellChangeTimes->{{3.539877427086914*^9, 3.5398774284140625`*^9}, 
   3.54038764191775*^9}],

Cell[BoxData[
 RowBox[{"Module", "[", 
  RowBox[{
   RowBox[{"{", 
    RowBox[{"a", ",", "b"}], "}"}], ",", "\t", "\n", "\t", 
   RowBox[{
    RowBox[{"a", "=", "1"}], ";", "\t", "\n", "\t", 
    RowBox[{"Block", "[", 
     RowBox[{
      RowBox[{"{", 
       RowBox[{"c", ",", "d"}], "}"}], ",", "\n", "\t", "\t", 
      RowBox[{
       RowBox[{"c", "=", 
        RowBox[{"a", "+", "1"}]}], ";", 
       RowBox[{"d", "=", 
        RowBox[{"b", "+", "2"}]}]}]}], "]"}], ";", "\n", "\t", "b"}]}], 
  "]"}]], "Input",
 GeneratedCell->True,
 CellAutoOverwrite->True,
 CellChangeTimes->{3.5398774290585938`*^9}]
}, Closed]],

Cell[CellGroupData[{

Cell["Example8", "Subsubsection",
 CellChangeTimes->{{3.5391592149648438`*^9, 3.5391592159570312`*^9}, 
   3.540401577008524*^9}],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"boxes7", " ", "=", " ", 
  RowBox[{"MakeBoxes", "[", 
   RowBox[{
    RowBox[{"Module", "[", 
     RowBox[{
      RowBox[{"{", 
       RowBox[{
        RowBox[{"ln", "=", 
         RowBox[{"Length", "@", "#"}]}], ",", "x"}], "}"}], ",", 
      RowBox[{
       RowBox[{"x", "=", 
        RowBox[{
         RowBox[{"#", "[", 
          RowBox[{"[", " ", 
           RowBox[{";;", 
            RowBox[{"Ceiling", "[", 
             RowBox[{"ln", "/", "2`"}], "]"}]}], "]"}], "]"}], "+", 
         RowBox[{"#", "[", 
          RowBox[{"[", 
           RowBox[{
            RowBox[{"-", "1"}], ";;", 
            RowBox[{
             RowBox[{"Floor", "[", 
              RowBox[{"ln", "/", "2`"}], "]"}], "+", "1"}], ";;", 
            RowBox[{"-", "1"}]}], "]"}], "]"}]}]}], ";", 
       "\[IndentingNewLine]", 
       RowBox[{"If", "[", 
        RowBox[{
         RowBox[{"OddQ", "@", "ln"}], ",", 
         RowBox[{
          RowBox[{"x", "[", 
           RowBox[{"[", 
            RowBox[{"-", "1"}], "]"}], "]"}], "/=", "2"}]}], "]"}], ";", 
       "\[IndentingNewLine]", "x"}]}], "]"}], "&"}], "]"}]}]], "Input"],

Cell[BoxData[
 RowBox[{"RowBox", "[", 
  RowBox[{"{", 
   RowBox[{
    RowBox[{"RowBox", "[", 
     RowBox[{"{", 
      RowBox[{"\<\"Module\"\>", ",", "\<\"[\"\>", ",", 
       RowBox[{"RowBox", "[", 
        RowBox[{"{", 
         RowBox[{
          RowBox[{"RowBox", "[", 
           RowBox[{"{", 
            RowBox[{"\<\"{\"\>", ",", 
             RowBox[{"RowBox", "[", 
              RowBox[{"{", 
               RowBox[{
                RowBox[{"RowBox", "[", 
                 RowBox[{"{", 
                  RowBox[{"\<\"ln\"\>", ",", "\<\"=\"\>", ",", 
                   RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"Length\"\>", ",", "\<\"[\"\>", 
                    ",", "\<\"#1\"\>", ",", "\<\"]\"\>"}], "}"}], "]"}]}], 
                  "}"}], "]"}], ",", "\<\",\"\>", ",", "\<\"x\"\>"}], "}"}], 
              "]"}], ",", "\<\"}\"\>"}], "}"}], "]"}], ",", "\<\",\"\>", ",", 
          
          RowBox[{"RowBox", "[", 
           RowBox[{"{", 
            RowBox[{
             RowBox[{"RowBox", "[", 
              RowBox[{"{", 
               RowBox[{"\<\"x\"\>", ",", "\<\"=\"\>", ",", 
                RowBox[{"RowBox", "[", 
                 RowBox[{"{", 
                  RowBox[{
                   RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"#1\"\>", ",", "\<\"\[LeftDoubleBracket]\"\>",
                     ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"1\"\>", ",", "\<\";;\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"Ceiling\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"FractionBox", "[", 
                    RowBox[{"\<\"ln\"\>", ",", "\<\"2.`\"\>"}], "]"}], 
                    ",", "\<\"]\"\>"}], "}"}], "]"}]}], "}"}], "]"}], 
                    ",", "\<\"\[RightDoubleBracket]\"\>"}], "}"}], "]"}], 
                   ",", "\<\"+\"\>", ",", 
                   RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"#1\"\>", ",", "\<\"\[LeftDoubleBracket]\"\>",
                     ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"-\"\>", ",", "\<\"1\"\>"}], "}"}], "]"}], 
                    ",", "\<\";;\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"Floor\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"FractionBox", "[", 
                    RowBox[{"\<\"ln\"\>", ",", "\<\"2.`\"\>"}], "]"}], 
                    ",", "\<\"]\"\>"}], "}"}], "]"}], ",", "\<\"+\"\>", 
                    ",", "\<\"1\"\>"}], "}"}], "]"}], ",", "\<\";;\"\>", ",", 
                    
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"-\"\>", ",", "\<\"1\"\>"}], "}"}], "]"}]}], 
                    "}"}], "]"}], ",", "\<\"\[RightDoubleBracket]\"\>"}], 
                    "}"}], "]"}]}], "}"}], "]"}]}], "}"}], "]"}], 
             ",", "\<\";\"\>", ",", 
             RowBox[{"RowBox", "[", 
              RowBox[{"{", 
               RowBox[{"\<\"If\"\>", ",", "\<\"[\"\>", ",", 
                RowBox[{"RowBox", "[", 
                 RowBox[{"{", 
                  RowBox[{
                   RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"OddQ\"\>", ",", "\<\"[\"\>", 
                    ",", "\<\"ln\"\>", ",", "\<\"]\"\>"}], "}"}], "]"}], 
                   ",", "\<\",\"\>", ",", 
                   RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"x\"\>", ",", "\<\"\[LeftDoubleBracket]\"\>", 
                    ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"-\"\>", ",", "\<\"1\"\>"}], "}"}], "]"}], 
                    ",", "\<\"\[RightDoubleBracket]\"\>"}], "}"}], "]"}], 
                    ",", "\<\"/=\"\>", ",", "\<\"2\"\>"}], "}"}], "]"}]}], 
                  "}"}], "]"}], ",", "\<\"]\"\>"}], "}"}], "]"}], 
             ",", "\<\";\"\>", ",", "\<\"x\"\>"}], "}"}], "]"}]}], "}"}], 
        "]"}], ",", "\<\"]\"\>"}], "}"}], "]"}], ",", "\<\"&\"\>"}], "}"}], 
  "]"}]], "Output",
 CellChangeTimes->{3.5379951049199843`*^9, 3.5387495529335938`*^9, 
  3.539159221930664*^9, 3.5398774887890625`*^9}]
}, Open  ]],

Cell[BoxData[
 RowBox[{"prn", "@", 
  RowBox[{"FullCodeFormat", "@", "boxes7"}]}]], "Input",
 CellChangeTimes->{
  3.5379951187871723`*^9, {3.539877493857422*^9, 3.539877495448242*^9}, 
   3.540387641963473*^9}],

Cell[BoxData[
 RowBox[{"\n", 
  RowBox[{
   RowBox[{"Module", "[", 
    RowBox[{
     RowBox[{"{", 
      RowBox[{
       RowBox[{"ln", "=", 
        RowBox[{"Length", "[", "#1", "]"}]}], ",", "x"}], "}"}], ",", "\t", 
     "\n", "\t", 
     RowBox[{
      RowBox[{"x", "=", 
       RowBox[{
        RowBox[{"#1", "\[LeftDoubleBracket]", 
         RowBox[{"1", ";;", 
          RowBox[{"Ceiling", "[", 
           FractionBox["ln", "2.`"], "]"}]}], "\[RightDoubleBracket]"}], "+", 
        
        RowBox[{"#1", "\[LeftDoubleBracket]", 
         RowBox[{
          RowBox[{"-", "1"}], ";;", 
          RowBox[{
           RowBox[{"Floor", "[", 
            FractionBox["ln", "2.`"], "]"}], "+", "1"}], ";;", 
          RowBox[{"-", "1"}]}], "\[RightDoubleBracket]"}]}]}], ";", "\n", 
      "\t", 
      RowBox[{"If", "[", 
       RowBox[{
        RowBox[{"OddQ", "[", "ln", "]"}], ",", 
        RowBox[{
         RowBox[{"x", "\[LeftDoubleBracket]", 
          RowBox[{"-", "1"}], "\[RightDoubleBracket]"}], "/=", "2"}]}], "]"}],
       ";", "\n", "\t", "x"}]}], "\n", "]"}], "&"}]}]], "Input",
 GeneratedCell->True,
 CellAutoOverwrite->True,
 CellChangeTimes->{3.539877497241211*^9}],

Cell[BoxData[
 RowBox[{"prn", "@", 
  RowBox[{"FullCodeFormatCompact", "@", "boxes7"}]}]], "Input",
 CellChangeTimes->{{3.5398775082802734`*^9, 3.53987750934375*^9}, 
   3.540387642008209*^9}],

Cell[BoxData[
 RowBox[{"\n", 
  RowBox[{
   RowBox[{"Module", "[", 
    RowBox[{
     RowBox[{"{", 
      RowBox[{
       RowBox[{"ln", "=", 
        RowBox[{"Length", "[", "#1", "]"}]}], ",", "x"}], "}"}], ",", "\t", 
     "\n", "\t", 
     RowBox[{
      RowBox[{"x", "=", 
       RowBox[{
        RowBox[{"#1", "\[LeftDoubleBracket]", 
         RowBox[{"1", ";;", 
          RowBox[{"Ceiling", "[", 
           FractionBox["ln", "2.`"], "]"}]}], "\[RightDoubleBracket]"}], "+", 
        
        RowBox[{"#1", "\[LeftDoubleBracket]", 
         RowBox[{
          RowBox[{"-", "1"}], ";;", 
          RowBox[{
           RowBox[{"Floor", "[", 
            FractionBox["ln", "2.`"], "]"}], "+", "1"}], ";;", 
          RowBox[{"-", "1"}]}], "\[RightDoubleBracket]"}]}]}], ";", "\n", 
      "\t", 
      RowBox[{"If", "[", 
       RowBox[{
        RowBox[{"OddQ", "[", "ln", "]"}], ",", 
        RowBox[{
         RowBox[{"x", "\[LeftDoubleBracket]", 
          RowBox[{"-", "1"}], "\[RightDoubleBracket]"}], "/=", "2"}]}], "]"}],
       ";", "\n", "\t", "x"}]}], "]"}], "&"}]}]], "Input",
 GeneratedCell->True,
 CellAutoOverwrite->True,
 CellChangeTimes->{3.5398775100722656`*^9}]
}, Closed]],

Cell[CellGroupData[{

Cell["Example9", "Subsubsection",
 CellChangeTimes->{{3.5391592768847656`*^9, 3.5391592778564453`*^9}, 
   3.540401577696081*^9}],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"boxes8", " ", "=", " ", "\[IndentingNewLine]", 
  RowBox[{"MakeBoxes", "[", 
   RowBox[{
    RowBox[{"symSum", "[", "li_List", "]"}], ":=", 
    RowBox[{"Module", "[", 
     RowBox[{
      RowBox[{"{", 
       RowBox[{"k2", "=", 
        RowBox[{"Ceiling", "[", 
         RowBox[{
          RowBox[{"Length", "[", "li", "]"}], "/", "2"}], "]"}]}], "}"}], ",", 
      RowBox[{"Total", "[", 
       RowBox[{"MapAt", "[", 
        RowBox[{"Reverse", ",", 
         RowBox[{
          RowBox[{
           RowBox[{"If", "[", 
            RowBox[{
             RowBox[{"Apply", "[", 
              RowBox[{"Equal", ",", 
               RowBox[{"Length", "/@", "#"}]}], "]"}], ",", "#", ",", 
             RowBox[{"MapAt", "[", 
              RowBox[{
               RowBox[{"Function", "[", 
                RowBox[{"l", ",", 
                 RowBox[{"PadLeft", "[", 
                  RowBox[{"l", ",", "k2"}], "]"}]}], "]"}], ",", "#", ",", 
               RowBox[{"{", "2", "}"}]}], "]"}]}], "]"}], "&"}], "[", 
          RowBox[{"Partition", "[", 
           RowBox[{"li", ",", "k2", ",", "k2", ",", 
            RowBox[{"{", 
             RowBox[{"1", ",", "1"}], "}"}], ",", 
            RowBox[{"{", "}"}]}], "]"}], "]"}], ",", 
         RowBox[{"{", "2", "}"}]}], "]"}], "]"}]}], "]"}]}], "]"}]}]], "Input"],

Cell[BoxData[
 RowBox[{"RowBox", "[", 
  RowBox[{"{", 
   RowBox[{
    RowBox[{"RowBox", "[", 
     RowBox[{"{", 
      RowBox[{"\<\"symSum\"\>", ",", "\<\"[\"\>", ",", "\<\"li_List\"\>", 
       ",", "\<\"]\"\>"}], "}"}], "]"}], ",", "\<\":=\"\>", ",", 
    RowBox[{"RowBox", "[", 
     RowBox[{"{", 
      RowBox[{"\<\"Module\"\>", ",", "\<\"[\"\>", ",", 
       RowBox[{"RowBox", "[", 
        RowBox[{"{", 
         RowBox[{
          RowBox[{"RowBox", "[", 
           RowBox[{"{", 
            RowBox[{"\<\"{\"\>", ",", 
             RowBox[{"RowBox", "[", 
              RowBox[{"{", 
               RowBox[{"\<\"k2\"\>", ",", "\<\"=\"\>", ",", 
                RowBox[{"RowBox", "[", 
                 RowBox[{"{", 
                  RowBox[{"\<\"Ceiling\"\>", ",", "\<\"[\"\>", ",", 
                   RowBox[{"FractionBox", "[", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"Length\"\>", ",", "\<\"[\"\>", 
                    ",", "\<\"li\"\>", ",", "\<\"]\"\>"}], "}"}], "]"}], 
                    ",", "\<\"2\"\>"}], "]"}], ",", "\<\"]\"\>"}], "}"}], 
                 "]"}]}], "}"}], "]"}], ",", "\<\"}\"\>"}], "}"}], "]"}], 
          ",", "\<\",\"\>", ",", 
          RowBox[{"RowBox", "[", 
           RowBox[{"{", 
            RowBox[{"\<\"Total\"\>", ",", "\<\"[\"\>", ",", 
             RowBox[{"RowBox", "[", 
              RowBox[{"{", 
               RowBox[{"\<\"MapAt\"\>", ",", "\<\"[\"\>", ",", 
                RowBox[{"RowBox", "[", 
                 RowBox[{"{", 
                  RowBox[{"\<\"Reverse\"\>", ",", "\<\",\"\>", ",", 
                   RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"(\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"If\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"Equal\"\>", ",", "\<\"@@\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"Length\"\>", ",", "\<\"/@\"\>", 
                    ",", "\<\"#1\"\>"}], "}"}], "]"}]}], "}"}], "]"}], 
                    ",", "\<\",\"\>", ",", "\<\"#1\"\>", ",", "\<\",\"\>", 
                    ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"MapAt\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"Function\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"l\"\>", ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"PadLeft\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"l\"\>", ",", "\<\",\"\>", 
                    ",", "\<\"k2\"\>"}], "}"}], "]"}], ",", "\<\"]\"\>"}], 
                    "}"}], "]"}]}], "}"}], "]"}], ",", "\<\"]\"\>"}], "}"}], 
                    "]"}], ",", "\<\",\"\>", ",", "\<\"#1\"\>", 
                    ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"{\"\>", ",", "\<\"2\"\>", ",", "\<\"}\"\>"}],
                     "}"}], "]"}]}], "}"}], "]"}], ",", "\<\"]\"\>"}], "}"}], 
                    "]"}]}], "}"}], "]"}], ",", "\<\"]\"\>"}], "}"}], "]"}], 
                    ",", "\<\"&\"\>"}], "}"}], "]"}], ",", "\<\")\"\>"}], 
                    "}"}], "]"}], ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"Partition\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"li\"\>", ",", "\<\",\"\>", ",", "\<\"k2\"\>",
                     ",", "\<\",\"\>", ",", "\<\"k2\"\>", ",", "\<\",\"\>", 
                    ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"{\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"1\"\>", ",", "\<\",\"\>", ",", "\<\"1\"\>"}],
                     "}"}], "]"}], ",", "\<\"}\"\>"}], "}"}], "]"}], 
                    ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"{\"\>", ",", "\<\"}\"\>"}], "}"}], "]"}]}], 
                    "}"}], "]"}], ",", "\<\"]\"\>"}], "}"}], "]"}], 
                    ",", "\<\"]\"\>"}], "}"}], "]"}], ",", "\<\",\"\>", ",", 
                   RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"{\"\>", ",", "\<\"2\"\>", ",", "\<\"}\"\>"}],
                     "}"}], "]"}]}], "}"}], "]"}], ",", "\<\"]\"\>"}], "}"}], 
              "]"}], ",", "\<\"]\"\>"}], "}"}], "]"}]}], "}"}], "]"}], 
       ",", "\<\"]\"\>"}], "}"}], "]"}]}], "}"}], "]"}]], "Output",
 CellChangeTimes->{3.537995678085024*^9, 3.5387552999560547`*^9, 
  3.5391592873828125`*^9, 3.5398775401015625`*^9}]
}, Open  ]],

Cell[BoxData[
 RowBox[{"prn", "@", 
  RowBox[{"FullCodeFormat", "@", "boxes8"}]}]], "Input",
 CellChangeTimes->{{3.5379956837774067`*^9, 3.537995684052797*^9}, {
   3.539877543798828*^9, 3.539877545419922*^9}, 3.540387642052734*^9}],

Cell[BoxData[
 RowBox[{
  RowBox[{"symSum", "[", "li_List", "]"}], ":=", "\n", "\t", 
  RowBox[{"Module", "[", 
   RowBox[{
    RowBox[{"{", 
     RowBox[{"k2", "=", 
      RowBox[{"Ceiling", "[", 
       FractionBox[
        RowBox[{"Length", "[", "li", "]"}], "2"], "]"}]}], "}"}], ",", "\n", 
    "\t", "\t", 
    RowBox[{"Total", "[", "\n", "\t", "\t", "\t", 
     RowBox[{
     "MapAt", "[", "\t", "\t", "\t", "\t", "\n", "\t", "\t", "\t", "\t", 
      RowBox[{
      "Reverse", ",", "\t", "\t", "\t", "\t", "\n", "\t", "\t", "\t", "\t", 
       RowBox[{
        RowBox[{
        "(", "\t", "\t", "\t", "\t", "\t", "\n", "\t", "\t", "\t", "\t", "\t", 
         RowBox[{
          RowBox[{"If", "[", "\n", "\t", "\t", "\t", "\t", "\t", "\t", 
           RowBox[{
            RowBox[{"Equal", "@@", 
             RowBox[{"Length", "/@", "#1"}]}], ",", "\n", "\t", "\t", "\t", 
            "\t", "\t", "\t", "#1", ",", "\n", "\t", "\t", "\t", "\t", "\t", 
            "\t", 
            RowBox[{"(*", " ", "else", " ", "*)"}], "\n", "\t", "\t", "\t", 
            "\t", "\t", "\t", 
            RowBox[{"MapAt", "[", 
             RowBox[{
              RowBox[{"Function", "[", 
               RowBox[{"l", ",", 
                RowBox[{"PadLeft", "[", 
                 RowBox[{"l", ",", "k2"}], "]"}]}], "]"}], ",", "#1", ",", 
              RowBox[{"{", "2", "}"}]}], "]"}]}], "\n", "\t", "\t", "\t", 
           "\t", "\t", "]"}], "&"}], "\n", "\t", "\t", "\t", "\t", ")"}], "[",
         "\n", "\t", "\t", "\t", "\t", "\t", 
        RowBox[{"Partition", "[", 
         RowBox[{"li", ",", "k2", ",", "k2", ",", 
          RowBox[{"{", 
           RowBox[{"1", ",", "1"}], "}"}], ",", 
          RowBox[{"{", "}"}]}], "]"}], "\n", "\t", "\t", "\t", "\t", "]"}], 
       ",", "\n", "\t", "\t", "\t", "\t", 
       RowBox[{"{", "2", "}"}]}], "\n", "\t", "\t", "\t", "]"}], "\n", "\t", 
     "\t", "]"}]}], "\n", "\t", "]"}]}]], "Input",
 GeneratedCell->True,
 CellAutoOverwrite->True,
 CellChangeTimes->{3.539877546229492*^9}],

Cell[BoxData[
 RowBox[{"prn", "@", 
  RowBox[{"FullCodeFormatCompact", "@", "boxes8"}]}]], "Input",
 CellChangeTimes->{{3.5398775569960938`*^9, 3.539877558051758*^9}, 
   3.540387642095895*^9}],

Cell[BoxData[
 RowBox[{
  RowBox[{"symSum", "[", "li_List", "]"}], ":=", "\n", "\t", 
  RowBox[{"Module", "[", 
   RowBox[{
    RowBox[{"{", 
     RowBox[{"k2", "=", 
      RowBox[{"Ceiling", "[", 
       FractionBox[
        RowBox[{"Length", "[", "li", "]"}], "2"], "]"}]}], "}"}], ",", "\n", 
    "\t", "\t", 
    RowBox[{"Total", "[", "\n", "\t", "\t", "\t", 
     RowBox[{
     "MapAt", "[", "\t", "\t", "\t", "\t", "\n", "\t", "\t", "\t", "\t", 
      RowBox[{
      "Reverse", ",", "\t", "\t", "\t", "\t", "\n", "\t", "\t", "\t", "\t", 
       RowBox[{
        RowBox[{
        "(", "\t", "\t", "\t", "\t", "\t", "\n", "\t", "\t", "\t", "\t", "\t", 
         RowBox[{
          RowBox[{"If", "[", "\n", "\t", "\t", "\t", "\t", "\t", "\t", 
           RowBox[{
            RowBox[{"Equal", "@@", 
             RowBox[{"Length", "/@", "#1"}]}], ",", "\n", "\t", "\t", "\t", 
            "\t", "\t", "\t", "#1", ",", "\n", "\t", "\t", "\t", "\t", "\t", 
            "\t", 
            RowBox[{"(*", " ", "else", " ", "*)"}], "\n", "\t", "\t", "\t", 
            "\t", "\t", "\t", 
            RowBox[{"MapAt", "[", 
             RowBox[{
              RowBox[{"Function", "[", 
               RowBox[{"l", ",", 
                RowBox[{"PadLeft", "[", 
                 RowBox[{"l", ",", "k2"}], "]"}]}], "]"}], ",", "#1", ",", 
              RowBox[{"{", "2", "}"}]}], "]"}]}], "]"}], "&"}], ")"}], "[", 
        "\n", "\t", "\t", "\t", "\t", "\t", 
        RowBox[{"Partition", "[", 
         RowBox[{"li", ",", "k2", ",", "k2", ",", 
          RowBox[{"{", 
           RowBox[{"1", ",", "1"}], "}"}], ",", 
          RowBox[{"{", "}"}]}], "]"}], "]"}], ",", "\n", "\t", "\t", "\t", 
       "\t", 
       RowBox[{"{", "2", "}"}]}], "]"}], "]"}]}], "]"}]}]], "Input",
 GeneratedCell->True,
 CellAutoOverwrite->True,
 CellChangeTimes->{3.5398775587802734`*^9}]
}, Closed]],

Cell[CellGroupData[{

Cell["Example10", "Subsubsection",
 CellChangeTimes->{{3.5391627734433594`*^9, 3.5391627749960938`*^9}, 
   3.540401578385727*^9}],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"boxes11", " ", "=", " ", 
  RowBox[{"MakeBoxes", "[", 
   RowBox[{
    RowBox[{"findMiddle", "[", "lst_", "]"}], ":=", 
    RowBox[{
     RowBox[{
      RowBox[{"If", "[", 
       RowBox[{
        RowBox[{"#", "\[Equal]", 
         RowBox[{"{", "}"}]}], ",", "$Failed", ",", 
        RowBox[{"First", "@", 
         RowBox[{"First", "@", "#"}]}]}], "]"}], "&"}], "@", 
     RowBox[{"Position", "[", 
      RowBox[{
       RowBox[{
        RowBox[{"Function", "[", 
         RowBox[{
          RowBox[{"{", "l", "}"}], ",", 
          RowBox[{"MapThread", "[", 
           RowBox[{"Equal", ",", 
            RowBox[{"{", 
             RowBox[{"l", ",", 
              RowBox[{"Reverse", "@", "l"}]}], "}"}]}], "]"}]}], "]"}], "@", 
        RowBox[{"MapIndexed", "[", 
         RowBox[{
          RowBox[{
           RowBox[{"First", "@", "#2"}], "&"}], ",", "lst"}], "]"}]}], ",", 
       "True"}], "]"}]}]}], "]"}]}]], "Input"],

Cell[BoxData[
 RowBox[{"RowBox", "[", 
  RowBox[{"{", 
   RowBox[{
    RowBox[{"RowBox", "[", 
     RowBox[{"{", 
      RowBox[{"\<\"findMiddle\"\>", ",", "\<\"[\"\>", ",", "\<\"lst_\"\>", 
       ",", "\<\"]\"\>"}], "}"}], "]"}], ",", "\<\":=\"\>", ",", 
    RowBox[{"RowBox", "[", 
     RowBox[{"{", 
      RowBox[{
       RowBox[{"RowBox", "[", 
        RowBox[{"{", 
         RowBox[{"\<\"(\"\>", ",", 
          RowBox[{"RowBox", "[", 
           RowBox[{"{", 
            RowBox[{
             RowBox[{"RowBox", "[", 
              RowBox[{"{", 
               RowBox[{"\<\"If\"\>", ",", "\<\"[\"\>", ",", 
                RowBox[{"RowBox", "[", 
                 RowBox[{"{", 
                  RowBox[{
                   RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"#1\"\>", ",", "\<\"\[Equal]\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"{\"\>", ",", "\<\"}\"\>"}], "}"}], "]"}]}], 
                    "}"}], "]"}], ",", "\<\",\"\>", ",", "\<\"$Failed\"\>", 
                   ",", "\<\",\"\>", ",", 
                   RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"First\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"First\"\>", ",", "\<\"[\"\>", 
                    ",", "\<\"#1\"\>", ",", "\<\"]\"\>"}], "}"}], "]"}], 
                    ",", "\<\"]\"\>"}], "}"}], "]"}]}], "}"}], "]"}], 
                ",", "\<\"]\"\>"}], "}"}], "]"}], ",", "\<\"&\"\>"}], "}"}], 
           "]"}], ",", "\<\")\"\>"}], "}"}], "]"}], ",", "\<\"[\"\>", ",", 
       RowBox[{"RowBox", "[", 
        RowBox[{"{", 
         RowBox[{"\<\"Position\"\>", ",", "\<\"[\"\>", ",", 
          RowBox[{"RowBox", "[", 
           RowBox[{"{", 
            RowBox[{
             RowBox[{"RowBox", "[", 
              RowBox[{"{", 
               RowBox[{
                RowBox[{"RowBox", "[", 
                 RowBox[{"{", 
                  RowBox[{"\<\"Function\"\>", ",", "\<\"[\"\>", ",", 
                   RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"{\"\>", ",", "\<\"l\"\>", ",", "\<\"}\"\>"}],
                     "}"}], "]"}], ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"MapThread\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"Equal\"\>", ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"{\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"l\"\>", ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"Reverse\"\>", ",", "\<\"[\"\>", 
                    ",", "\<\"l\"\>", ",", "\<\"]\"\>"}], "}"}], "]"}]}], 
                    "}"}], "]"}], ",", "\<\"}\"\>"}], "}"}], "]"}]}], "}"}], 
                    "]"}], ",", "\<\"]\"\>"}], "}"}], "]"}]}], "}"}], "]"}], 
                   ",", "\<\"]\"\>"}], "}"}], "]"}], ",", "\<\"[\"\>", ",", 
                RowBox[{"RowBox", "[", 
                 RowBox[{"{", 
                  RowBox[{"\<\"MapIndexed\"\>", ",", "\<\"[\"\>", ",", 
                   RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"First\"\>", ",", "\<\"[\"\>", 
                    ",", "\<\"#2\"\>", ",", "\<\"]\"\>"}], "}"}], "]"}], 
                    ",", "\<\"&\"\>"}], "}"}], "]"}], ",", "\<\",\"\>", 
                    ",", "\<\"lst\"\>"}], "}"}], "]"}], ",", "\<\"]\"\>"}], 
                  "}"}], "]"}], ",", "\<\"]\"\>"}], "}"}], "]"}], 
             ",", "\<\",\"\>", ",", "\<\"True\"\>"}], "}"}], "]"}], 
          ",", "\<\"]\"\>"}], "}"}], "]"}], ",", "\<\"]\"\>"}], "}"}], 
     "]"}]}], "}"}], "]"}]], "Output",
 CellChangeTimes->{3.5379957650371723`*^9, 3.538749560330078*^9, 
  3.5391627817421875`*^9, 3.539877961361328*^9}]
}, Open  ]],

Cell[BoxData[
 RowBox[{
  RowBox[{"prn", "@", 
   RowBox[{"FullCodeFormat", "@", "boxes11"}]}], 
  "\[IndentingNewLine]"}]], "Input",
 CellChangeTimes->{{3.537995762229555*^9, 3.537995773764711*^9}, {
   3.5398779573398438`*^9, 3.5398779593427734`*^9}, 3.540387642138858*^9}],

Cell[BoxData[
 RowBox[{
  RowBox[{"findMiddle", "[", "lst_", "]"}], ":=", "\n", "\t", 
  RowBox[{
   RowBox[{"(", 
    RowBox[{
     RowBox[{"If", "[", 
      RowBox[{
       RowBox[{"#1", "\[Equal]", 
        RowBox[{"{", "}"}]}], ",", "$Failed", ",", 
       RowBox[{"First", "[", 
        RowBox[{"First", "[", "#1", "]"}], "]"}]}], "]"}], "&"}], ")"}], "[", 
   "\n", "\t", "\t", 
   RowBox[{"Position", "[", "\t", "\t", "\t", "\n", "\t", "\t", "\t", 
    RowBox[{
     RowBox[{
      RowBox[{"Function", "[", 
       RowBox[{
        RowBox[{"{", "l", "}"}], ",", 
        RowBox[{"MapThread", "[", 
         RowBox[{"Equal", ",", 
          RowBox[{"{", 
           RowBox[{"l", ",", 
            RowBox[{"Reverse", "[", "l", "]"}]}], "}"}]}], "]"}]}], "]"}], 
      "[", "\n", "\t", "\t", "\t", "\t", 
      RowBox[{"MapIndexed", "[", 
       RowBox[{
        RowBox[{
         RowBox[{"First", "[", "#2", "]"}], "&"}], ",", "lst"}], "]"}], "\n", 
      "\t", "\t", "\t", "]"}], ",", "\n", "\t", "\t", "\t", "True"}], "\n", 
    "\t", "\t", "]"}], "\n", "\t", "]"}]}]], "Input",
 GeneratedCell->True,
 CellAutoOverwrite->True,
 CellChangeTimes->{3.5398779637646484`*^9}],

Cell[BoxData[
 RowBox[{
  RowBox[{"prn", "@", 
   RowBox[{"FullCodeFormatCompact", "@", "boxes11"}]}], 
  "\[IndentingNewLine]"}]], "Input",
 CellChangeTimes->{{3.5398779773007812`*^9, 3.539877978435547*^9}, 
   3.540387642181657*^9}],

Cell[BoxData[
 RowBox[{
  RowBox[{"findMiddle", "[", "lst_", "]"}], ":=", "\n", "\t", 
  RowBox[{
   RowBox[{"(", 
    RowBox[{
     RowBox[{"If", "[", 
      RowBox[{
       RowBox[{"#1", "\[Equal]", 
        RowBox[{"{", "}"}]}], ",", "$Failed", ",", 
       RowBox[{"First", "[", 
        RowBox[{"First", "[", "#1", "]"}], "]"}]}], "]"}], "&"}], ")"}], "[", 
   "\n", "\t", "\t", 
   RowBox[{"Position", "[", "\t", "\t", "\t", "\n", "\t", "\t", "\t", 
    RowBox[{
     RowBox[{
      RowBox[{"Function", "[", 
       RowBox[{
        RowBox[{"{", "l", "}"}], ",", 
        RowBox[{"MapThread", "[", 
         RowBox[{"Equal", ",", 
          RowBox[{"{", 
           RowBox[{"l", ",", 
            RowBox[{"Reverse", "[", "l", "]"}]}], "}"}]}], "]"}]}], "]"}], 
      "[", "\n", "\t", "\t", "\t", "\t", 
      RowBox[{"MapIndexed", "[", 
       RowBox[{
        RowBox[{
         RowBox[{"First", "[", "#2", "]"}], "&"}], ",", "lst"}], "]"}], "]"}],
      ",", "\n", "\t", "\t", "\t", "True"}], "]"}], "]"}]}]], "Input",
 GeneratedCell->True,
 CellAutoOverwrite->True,
 CellChangeTimes->{3.5398779792373047`*^9}]
}, Closed]],

Cell[CellGroupData[{

Cell["Example11", "Subsubsection",
 CellChangeTimes->{{3.5391627969179688`*^9, 3.5391627996132812`*^9}, 
   3.540401579017895*^9}],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"boxes13", "=", " ", "\[IndentingNewLine]", 
  RowBox[{"MakeBoxes", "[", 
   RowBox[{
    RowBox[{"ClearAll", "[", "removingModule", "]"}], ";", "\n", 
    RowBox[{"SetAttributes", "[", 
     RowBox[{"removingModule", ",", "HoldAll"}], "]"}], ";", "\n", 
    RowBox[{
     RowBox[{"removingModule", "[", 
      RowBox[{"vars_", ",", "body_"}], "]"}], ":=", 
     RowBox[{"Module", "[", 
      RowBox[{"vars", ",", 
       RowBox[{"CleanUp", "[", 
        RowBox[{"body", ",", 
         RowBox[{"ReleaseHold", "@", 
          RowBox[{"Replace", "[", 
           RowBox[{
            RowBox[{"HoldComplete", "[", "vars", "]"}], ",", 
            RowBox[{"{", 
             RowBox[{
              RowBox[{
               RowBox[{"HoldPattern", "[", 
                RowBox[{"a_Symbol", "=", "rhs_"}], "]"}], "\[RuleDelayed]", 
               RowBox[{"remove", "[", "a", "]"}]}], ",", 
              RowBox[{
               RowBox[{"HoldPattern", "[", "a_Symbol", "]"}], 
               "\[RuleDelayed]", 
               RowBox[{"remove", "[", "a", "]"}]}]}], "}"}], ",", 
            RowBox[{"{", "2", "}"}]}], "]"}]}]}], "]"}]}], "]"}]}], ";"}], 
   "]"}]}]], "Input",
 CellChangeTimes->{{3.5379958703213515`*^9, 3.5379958923643208`*^9}}],

Cell[BoxData[
 RowBox[{"RowBox", "[", 
  RowBox[{"{", 
   RowBox[{
    RowBox[{"RowBox", "[", 
     RowBox[{"{", 
      RowBox[{"\<\"ClearAll\"\>", ",", "\<\"[\"\>", 
       ",", "\<\"removingModule\"\>", ",", "\<\"]\"\>"}], "}"}], "]"}], 
    ",", "\<\";\"\>", ",", 
    RowBox[{"RowBox", "[", 
     RowBox[{"{", 
      RowBox[{"\<\"SetAttributes\"\>", ",", "\<\"[\"\>", ",", 
       RowBox[{"RowBox", "[", 
        RowBox[{"{", 
         RowBox[{"\<\"removingModule\"\>", ",", "\<\",\"\>", 
          ",", "\<\"HoldAll\"\>"}], "}"}], "]"}], ",", "\<\"]\"\>"}], "}"}], 
     "]"}], ",", "\<\";\"\>", ",", 
    RowBox[{"RowBox", "[", 
     RowBox[{"{", 
      RowBox[{
       RowBox[{"RowBox", "[", 
        RowBox[{"{", 
         RowBox[{"\<\"removingModule\"\>", ",", "\<\"[\"\>", ",", 
          RowBox[{"RowBox", "[", 
           RowBox[{"{", 
            RowBox[{"\<\"vars_\"\>", ",", "\<\",\"\>", ",", "\<\"body_\"\>"}],
             "}"}], "]"}], ",", "\<\"]\"\>"}], "}"}], "]"}], 
       ",", "\<\":=\"\>", ",", 
       RowBox[{"RowBox", "[", 
        RowBox[{"{", 
         RowBox[{"\<\"Module\"\>", ",", "\<\"[\"\>", ",", 
          RowBox[{"RowBox", "[", 
           RowBox[{"{", 
            RowBox[{"\<\"vars\"\>", ",", "\<\",\"\>", ",", 
             RowBox[{"RowBox", "[", 
              RowBox[{"{", 
               RowBox[{"\<\"CleanUp\"\>", ",", "\<\"[\"\>", ",", 
                RowBox[{"RowBox", "[", 
                 RowBox[{"{", 
                  RowBox[{"\<\"body\"\>", ",", "\<\",\"\>", ",", 
                   RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"ReleaseHold\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"Replace\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"HoldComplete\"\>", ",", "\<\"[\"\>", 
                    ",", "\<\"vars\"\>", ",", "\<\"]\"\>"}], "}"}], "]"}], 
                    ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"{\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"HoldPattern\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"a_Symbol\"\>", ",", "\<\"=\"\>", 
                    ",", "\<\"rhs_\"\>"}], "}"}], "]"}], ",", "\<\"]\"\>"}], 
                    "}"}], "]"}], ",", "\<\"\[RuleDelayed]\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"remove\"\>", ",", "\<\"[\"\>", 
                    ",", "\<\"a\"\>", ",", "\<\"]\"\>"}], "}"}], "]"}]}], 
                    "}"}], "]"}], ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"HoldPattern\"\>", ",", "\<\"[\"\>", 
                    ",", "\<\"a_Symbol\"\>", ",", "\<\"]\"\>"}], "}"}], "]"}],
                     ",", "\<\"\[RuleDelayed]\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"remove\"\>", ",", "\<\"[\"\>", 
                    ",", "\<\"a\"\>", ",", "\<\"]\"\>"}], "}"}], "]"}]}], 
                    "}"}], "]"}]}], "}"}], "]"}], ",", "\<\"}\"\>"}], "}"}], 
                    "]"}], ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"{\"\>", ",", "\<\"2\"\>", ",", "\<\"}\"\>"}],
                     "}"}], "]"}]}], "}"}], "]"}], ",", "\<\"]\"\>"}], "}"}], 
                    "]"}], ",", "\<\"]\"\>"}], "}"}], "]"}]}], "}"}], "]"}], 
                ",", "\<\"]\"\>"}], "}"}], "]"}]}], "}"}], "]"}], 
          ",", "\<\"]\"\>"}], "}"}], "]"}]}], "}"}], "]"}], 
    ",", "\<\";\"\>"}], "}"}], "]"}]], "Output",
 CellChangeTimes->{3.5379958931699843`*^9, 3.538749575705078*^9, 
  3.5391628138671875`*^9, 3.539877994654297*^9}]
}, Open  ]],

Cell[BoxData[
 RowBox[{"prn", "@", 
  RowBox[{"FullCodeFormat", "@", "boxes13"}]}]], "Input",
 CellChangeTimes->{{3.537995901490297*^9, 3.5379959017949843`*^9}, {
   3.539878000850586*^9, 3.5398780068125*^9}, 3.540387642224124*^9}],

Cell[BoxData[
 RowBox[{"\n", 
  RowBox[{
   RowBox[{
    RowBox[{"ClearAll", "[", "removingModule", "]"}], ";"}], "\n", 
   RowBox[{
    RowBox[{"SetAttributes", "[", 
     RowBox[{"removingModule", ",", "HoldAll"}], "]"}], ";"}], "\n", 
   RowBox[{
    RowBox[{
     RowBox[{"removingModule", "[", 
      RowBox[{"vars_", ",", "body_"}], "]"}], ":=", "\n", "\t", 
     RowBox[{"Module", "[", "\t", "\t", "\n", "\t", "\t", 
      RowBox[{"vars", ",", "\n", "\t", "\t", 
       RowBox[{"CleanUp", "[", "\t", "\t", "\t", "\n", "\t", "\t", "\t", 
        RowBox[{"body", ",", "\n", "\t", "\t", "\t", 
         RowBox[{"ReleaseHold", "[", "\n", "\t", "\t", "\t", "\t", 
          RowBox[{
          "Replace", "[", "\t", "\t", "\t", "\t", "\t", "\n", "\t", "\t", 
           "\t", "\t", "\t", 
           RowBox[{
            RowBox[{"HoldComplete", "[", "vars", "]"}], ",", "\n", "\t", "\t",
             "\t", "\t", "\t", 
            RowBox[{
            "{", "\t", "\t", "\t", "\t", "\t", "\t", "\n", "\t", "\t", "\t", 
             "\t", "\t", "\t", 
             RowBox[{
              RowBox[{
               RowBox[{"HoldPattern", "[", 
                RowBox[{"a_Symbol", "=", "rhs_"}], "]"}], "\[RuleDelayed]", 
               RowBox[{"remove", "[", "a", "]"}]}], ",", "\n", "\t", "\t", 
              "\t", "\t", "\t", "\t", 
              RowBox[{
               RowBox[{"HoldPattern", "[", "a_Symbol", "]"}], 
               "\[RuleDelayed]", 
               RowBox[{"remove", "[", "a", "]"}]}]}], "\n", "\t", "\t", "\t", 
             "\t", "\t", "}"}], ",", "\n", "\t", "\t", "\t", "\t", "\t", 
            RowBox[{"{", "2", "}"}]}], "\n", "\t", "\t", "\t", "\t", "]"}], 
          "\n", "\t", "\t", "\t", "]"}]}], "\n", "\t", "\t", "]"}]}], "\n", 
      "\t", "]"}]}], ";"}]}]}]], "Input",
 GeneratedCell->True,
 CellAutoOverwrite->True,
 CellChangeTimes->{3.5398780030029297`*^9}],

Cell[BoxData[
 RowBox[{"prn", "@", 
  RowBox[{"FullCodeFormatCompact", "@", "boxes13"}]}]], "Input",
 CellChangeTimes->{{3.53987801784375*^9, 3.539878019536133*^9}, 
   3.540387642267761*^9}],

Cell[BoxData[
 RowBox[{"\n", 
  RowBox[{
   RowBox[{
    RowBox[{"ClearAll", "[", "removingModule", "]"}], ";"}], "\n", 
   RowBox[{
    RowBox[{"SetAttributes", "[", 
     RowBox[{"removingModule", ",", "HoldAll"}], "]"}], ";"}], "\n", 
   RowBox[{
    RowBox[{
     RowBox[{"removingModule", "[", 
      RowBox[{"vars_", ",", "body_"}], "]"}], ":=", "\n", "\t", 
     RowBox[{"Module", "[", "\t", "\t", "\n", "\t", "\t", 
      RowBox[{"vars", ",", "\n", "\t", "\t", 
       RowBox[{"CleanUp", "[", "\t", "\t", "\t", "\n", "\t", "\t", "\t", 
        RowBox[{"body", ",", "\n", "\t", "\t", "\t", 
         RowBox[{"ReleaseHold", "[", "\n", "\t", "\t", "\t", "\t", 
          RowBox[{
          "Replace", "[", "\t", "\t", "\t", "\t", "\t", "\n", "\t", "\t", 
           "\t", "\t", "\t", 
           RowBox[{
            RowBox[{"HoldComplete", "[", "vars", "]"}], ",", "\n", "\t", "\t",
             "\t", "\t", "\t", 
            RowBox[{
            "{", "\t", "\t", "\t", "\t", "\t", "\t", "\n", "\t", "\t", "\t", 
             "\t", "\t", "\t", 
             RowBox[{
              RowBox[{
               RowBox[{"HoldPattern", "[", 
                RowBox[{"a_Symbol", "=", "rhs_"}], "]"}], "\[RuleDelayed]", 
               RowBox[{"remove", "[", "a", "]"}]}], ",", "\n", "\t", "\t", 
              "\t", "\t", "\t", "\t", 
              RowBox[{
               RowBox[{"HoldPattern", "[", "a_Symbol", "]"}], 
               "\[RuleDelayed]", 
               RowBox[{"remove", "[", "a", "]"}]}]}], "}"}], ",", "\n", "\t", 
            "\t", "\t", "\t", "\t", 
            RowBox[{"{", "2", "}"}]}], "]"}], "]"}]}], "]"}]}], "]"}]}], 
    ";"}]}]}]], "Input",
 GeneratedCell->True,
 CellAutoOverwrite->True,
 CellChangeTimes->{3.539878020192383*^9}]
}, Closed]],

Cell[CellGroupData[{

Cell["Example12", "Subsubsection",
 CellChangeTimes->{{3.539162830729492*^9, 3.5391628315351562`*^9}, 
   3.540401579677536*^9}],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"boxes14", " ", "=", " ", 
  RowBox[{"MakeBoxes", "[", 
   RowBox[{
    RowBox[{"ClearAll", "[", "getVersionSince", "]"}], ";", 
    "\[IndentingNewLine]", 
    RowBox[{
     RowBox[{"getVersionSince", "::", "fail"}], " ", "=", " ", 
     "\"\<Unable to extract version information for function `1`\>\""}], ";", 
    "\[IndentingNewLine]", 
    RowBox[{
     RowBox[{"getVersionSince", "[", 
      RowBox[{"file_String", "?", "FileExistsQ"}], "]"}], ":=", 
     "\[IndentingNewLine]", 
     RowBox[{"With", "[", 
      RowBox[{
       RowBox[{"{", 
        RowBox[{"nb", " ", "=", " ", 
         RowBox[{"NotebookOpen", "[", 
          RowBox[{"file", ",", 
           RowBox[{"Visible", "\[Rule]", "False"}]}], "]"}]}], "}"}], ",", 
       "\[IndentingNewLine]", 
       RowBox[{
        RowBox[{"With", "[", 
         RowBox[{
          RowBox[{"{", 
           RowBox[{"res", " ", "=", " ", "\[IndentingNewLine]", 
            RowBox[{"Cases", "[", "\[IndentingNewLine]", 
             RowBox[{
              RowBox[{"NotebookGet", "[", "nb", "]"}], ",", 
              "\[IndentingNewLine]", 
              RowBox[{
               RowBox[{"Cell", "[", 
                RowBox[{"s_String", ",", "\"\<History\>\"", ",", "___"}], 
                "]"}], 
               RowBox[{"(*", 
                RowBox[{"/;", 
                 RowBox[{"StringMatchQ", "[", 
                  RowBox[{"s", ",", 
                   RowBox[{"\"\<New in\>\"", "~~", "__"}]}], "]"}]}], "*)"}], 
               "\[RuleDelayed]", "\[IndentingNewLine]", 
               RowBox[{"StringCases", "[", 
                RowBox[{
                 RowBox[{"StringTrim", "@", "s"}], ",", "\[IndentingNewLine]", 
                 RowBox[{"{", 
                  RowBox[{
                   RowBox[{
                    RowBox[{"\"\<New in\>\"", "~~", 
                    RowBox[{"(", 
                    RowBox[{"Whitespace", "|", "\"\<\>\""}], ")"}], "~~", 
                    RowBox[{"d", ":", 
                    RowBox[{"(", 
                    RowBox[{
                    RowBox[{"(", 
                    RowBox[{"DigitCharacter", "|", "\"\<.\>\""}], ")"}], 
                    ".."}], ")"}]}], "~~", "__", "~~", 
                    "\"\<Last modified in\>\"", "~~", 
                    RowBox[{"(", 
                    RowBox[{"Whitespace", "|", "\"\<\>\""}], ")"}], "~~", 
                    RowBox[{"m", ":", 
                    RowBox[{"(", 
                    RowBox[{"(", 
                    RowBox[{
                    RowBox[{"(", 
                    RowBox[{"DigitCharacter", "|", "\"\<.\>\""}], ")"}], 
                    ".."}], ")"}], ")"}]}]}], "\[RuleDelayed]", 
                    "\[IndentingNewLine]", 
                    RowBox[{"{", 
                    RowBox[{"d", ",", "m"}], "}"}]}], ",", 
                   "\[IndentingNewLine]", 
                   RowBox[{
                    RowBox[{"\"\<New in\>\"", "~~", 
                    RowBox[{"(", 
                    RowBox[{"Whitespace", "|", "\"\<\>\""}], ")"}], "~~", 
                    RowBox[{"d", ":", 
                    RowBox[{"(", 
                    RowBox[{
                    RowBox[{"(", 
                    RowBox[{"DigitCharacter", "|", "\"\<.\>\""}], ")"}], 
                    ".."}], ")"}]}]}], "\[RuleDelayed]", "d"}]}], "}"}]}], 
                "]"}]}], ",", "\[IndentingNewLine]", "Infinity"}], "]"}]}], 
           "}"}], ",", "\[IndentingNewLine]", 
          RowBox[{
           RowBox[{"NotebookClose", "[", "nb", "]"}], ";", 
           "\[IndentingNewLine]", 
           RowBox[{
            RowBox[{"First", "@", "res"}], "/;", 
            RowBox[{"res", "=!=", 
             RowBox[{"{", "}"}]}]}]}]}], "]"}], "/;", 
        RowBox[{"nb", "=!=", "$Failed"}]}]}], "]"}]}], ";", 
    "\[IndentingNewLine]", 
    RowBox[{
     RowBox[{"getVersionSince", "[", 
      RowBox[{"file_String", "?", "FileExistsQ"}], "]"}], ":=", 
     "\[IndentingNewLine]", 
     RowBox[{"(", 
      RowBox[{
       RowBox[{"Message", "[", 
        RowBox[{
         RowBox[{"getVersionSince", "::", "fail"}], ",", 
         RowBox[{"Style", "[", 
          RowBox[{
           RowBox[{"FileBaseName", "[", "file", "]"}], ",", "Red"}], "]"}]}], 
        "]"}], ";", "$Failed"}], ")"}]}], ";"}], "\[IndentingNewLine]", 
   "]"}]}]], "Input",
 CellChangeTimes->{{3.5387510115283203`*^9, 3.538751017921875*^9}}],

Cell[BoxData[
 RowBox[{"RowBox", "[", 
  RowBox[{"{", 
   RowBox[{
    RowBox[{"RowBox", "[", 
     RowBox[{"{", 
      RowBox[{"\<\"ClearAll\"\>", ",", "\<\"[\"\>", 
       ",", "\<\"getVersionSince\"\>", ",", "\<\"]\"\>"}], "}"}], "]"}], 
    ",", "\<\";\"\>", ",", 
    RowBox[{"RowBox", "[", 
     RowBox[{"{", 
      RowBox[{
       RowBox[{"StyleBox", "[", 
        RowBox[{
         RowBox[{"RowBox", "[", 
          RowBox[{"{", 
           
           RowBox[{"\<\"getVersionSince\"\>", ",", "\<\"::\"\>", 
            ",", "\<\"fail\"\>"}], "}"}], "]"}], ",", "\<\"MessageName\"\>"}],
         "]"}], ",", "\<\"=\"\>", 
       ",", "\<\"\\\"Unable to extract version information for function `1`\\\
\"\"\>"}], "}"}], "]"}], ",", "\<\";\"\>", ",", 
    RowBox[{"RowBox", "[", 
     RowBox[{"{", 
      RowBox[{
       RowBox[{"RowBox", "[", 
        RowBox[{"{", 
         RowBox[{"\<\"getVersionSince\"\>", ",", "\<\"[\"\>", ",", 
          RowBox[{"RowBox", "[", 
           RowBox[{"{", 
            
            RowBox[{"\<\"file_String\"\>", ",", "\<\"?\"\>", 
             ",", "\<\"FileExistsQ\"\>"}], "}"}], "]"}], ",", "\<\"]\"\>"}], 
         "}"}], "]"}], ",", "\<\":=\"\>", ",", 
       RowBox[{"RowBox", "[", 
        RowBox[{"{", 
         RowBox[{"\<\"With\"\>", ",", "\<\"[\"\>", ",", 
          RowBox[{"RowBox", "[", 
           RowBox[{"{", 
            RowBox[{
             RowBox[{"RowBox", "[", 
              RowBox[{"{", 
               RowBox[{"\<\"{\"\>", ",", 
                RowBox[{"RowBox", "[", 
                 RowBox[{"{", 
                  RowBox[{"\<\"nb\"\>", ",", "\<\"=\"\>", ",", 
                   RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"NotebookOpen\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"file\"\>", ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"Visible\"\>", ",", "\<\"\[Rule]\"\>", 
                    ",", "\<\"False\"\>"}], "}"}], "]"}]}], "}"}], "]"}], 
                    ",", "\<\"]\"\>"}], "}"}], "]"}]}], "}"}], "]"}], 
                ",", "\<\"}\"\>"}], "}"}], "]"}], ",", "\<\",\"\>", ",", 
             RowBox[{"RowBox", "[", 
              RowBox[{"{", 
               RowBox[{
                RowBox[{"RowBox", "[", 
                 RowBox[{"{", 
                  RowBox[{"\<\"With\"\>", ",", "\<\"[\"\>", ",", 
                   RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"{\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"res\"\>", ",", "\<\"=\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"Cases\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"NotebookGet\"\>", ",", "\<\"[\"\>", 
                    ",", "\<\"nb\"\>", ",", "\<\"]\"\>"}], "}"}], "]"}], 
                    ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"Cell\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"s_String\"\>", ",", "\<\",\"\>", 
                    ",", "\<\"\\\"History\\\"\"\>", ",", "\<\",\"\>", 
                    ",", "\<\"___\"\>"}], "}"}], "]"}], ",", "\<\"]\"\>"}], 
                    "}"}], "]"}], ",", "\<\"\[RuleDelayed]\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"StringCases\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"StringTrim\"\>", ",", "\<\"[\"\>", 
                    ",", "\<\"s\"\>", ",", "\<\"]\"\>"}], "}"}], "]"}], 
                    ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"{\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"\\\"New in\\\"\"\>", ",", "\<\"~~\"\>", ",", 
                    
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"Whitespace\"\>", ",", "\<\"|\"\>", 
                    ",", "\<\"\\\"\\\"\"\>"}], "}"}], "]"}], 
                    ",", "\<\"~~\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"d\"\>", ",", "\<\":\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"(\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"(\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"DigitCharacter\"\>", ",", "\<\"|\"\>", 
                    ",", "\<\"\\\".\\\"\"\>"}], "}"}], "]"}], 
                    ",", "\<\")\"\>"}], "}"}], "]"}], ",", "\<\"..\"\>"}], 
                    "}"}], "]"}], ",", "\<\")\"\>"}], "}"}], "]"}]}], "}"}], 
                    "]"}], ",", "\<\"~~\"\>", ",", "\<\"__\"\>", 
                    ",", "\<\"~~\"\>", 
                    ",", "\<\"\\\"Last modified in\\\"\"\>", 
                    ",", "\<\"~~\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"Whitespace\"\>", ",", "\<\"|\"\>", 
                    ",", "\<\"\\\"\\\"\"\>"}], "}"}], "]"}], 
                    ",", "\<\"~~\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"m\"\>", ",", "\<\":\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"(\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"(\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"DigitCharacter\"\>", ",", "\<\"|\"\>", 
                    ",", "\<\"\\\".\\\"\"\>"}], "}"}], "]"}], 
                    ",", "\<\")\"\>"}], "}"}], "]"}], ",", "\<\"..\"\>"}], 
                    "}"}], "]"}], ",", "\<\")\"\>"}], "}"}], "]"}]}], "}"}], 
                    "]"}]}], "}"}], "]"}], ",", "\<\"\[RuleDelayed]\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"{\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"d\"\>", ",", "\<\",\"\>", ",", "\<\"m\"\>"}],
                     "}"}], "]"}], ",", "\<\"}\"\>"}], "}"}], "]"}]}], "}"}], 
                    "]"}], ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"\\\"New in\\\"\"\>", ",", "\<\"~~\"\>", ",", 
                    
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"Whitespace\"\>", ",", "\<\"|\"\>", 
                    ",", "\<\"\\\"\\\"\"\>"}], "}"}], "]"}], 
                    ",", "\<\"~~\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"d\"\>", ",", "\<\":\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"(\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"(\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"DigitCharacter\"\>", ",", "\<\"|\"\>", 
                    ",", "\<\"\\\".\\\"\"\>"}], "}"}], "]"}], 
                    ",", "\<\")\"\>"}], "}"}], "]"}], ",", "\<\"..\"\>"}], 
                    "}"}], "]"}], ",", "\<\")\"\>"}], "}"}], "]"}]}], "}"}], 
                    "]"}]}], "}"}], "]"}], ",", "\<\"\[RuleDelayed]\"\>", 
                    ",", "\<\"d\"\>"}], "}"}], "]"}]}], "}"}], "]"}], 
                    ",", "\<\"}\"\>"}], "}"}], "]"}]}], "}"}], "]"}], 
                    ",", "\<\"]\"\>"}], "}"}], "]"}]}], "}"}], "]"}], 
                    ",", "\<\",\"\>", ",", "\<\"\[Infinity]\"\>"}], "}"}], 
                    "]"}], ",", "\<\"]\"\>"}], "}"}], "]"}]}], "}"}], "]"}], 
                    ",", "\<\"}\"\>"}], "}"}], "]"}], ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"NotebookClose\"\>", ",", "\<\"[\"\>", 
                    ",", "\<\"nb\"\>", ",", "\<\"]\"\>"}], "}"}], "]"}], 
                    ",", "\<\";\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"First\"\>", ",", "\<\"[\"\>", 
                    ",", "\<\"res\"\>", ",", "\<\"]\"\>"}], "}"}], "]"}], 
                    ",", "\<\"/;\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"res\"\>", ",", "\<\"=!=\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"{\"\>", ",", "\<\"}\"\>"}], "}"}], "]"}]}], 
                    "}"}], "]"}]}], "}"}], "]"}]}], "}"}], "]"}]}], "}"}], 
                    "]"}], ",", "\<\"]\"\>"}], "}"}], "]"}], 
                ",", "\<\"/;\"\>", ",", 
                RowBox[{"RowBox", "[", 
                 RowBox[{"{", 
                  
                  RowBox[{"\<\"nb\"\>", ",", "\<\"=!=\"\>", 
                   ",", "\<\"$Failed\"\>"}], "}"}], "]"}]}], "}"}], "]"}]}], 
            "}"}], "]"}], ",", "\<\"]\"\>"}], "}"}], "]"}]}], "}"}], "]"}], 
    ",", "\<\";\"\>", ",", 
    RowBox[{"RowBox", "[", 
     RowBox[{"{", 
      RowBox[{
       RowBox[{"RowBox", "[", 
        RowBox[{"{", 
         RowBox[{"\<\"getVersionSince\"\>", ",", "\<\"[\"\>", ",", 
          RowBox[{"RowBox", "[", 
           RowBox[{"{", 
            
            RowBox[{"\<\"file_String\"\>", ",", "\<\"?\"\>", 
             ",", "\<\"FileExistsQ\"\>"}], "}"}], "]"}], ",", "\<\"]\"\>"}], 
         "}"}], "]"}], ",", "\<\":=\"\>", ",", 
       RowBox[{"RowBox", "[", 
        RowBox[{"{", 
         RowBox[{"\<\"(\"\>", ",", 
          RowBox[{"RowBox", "[", 
           RowBox[{"{", 
            RowBox[{
             RowBox[{"RowBox", "[", 
              RowBox[{"{", 
               RowBox[{"\<\"Message\"\>", ",", "\<\"[\"\>", ",", 
                RowBox[{"RowBox", "[", 
                 RowBox[{"{", 
                  RowBox[{
                   RowBox[{"StyleBox", "[", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"getVersionSince\"\>", ",", "\<\"::\"\>", 
                    ",", "\<\"fail\"\>"}], "}"}], "]"}], 
                    ",", "\<\"MessageName\"\>"}], "]"}], ",", "\<\",\"\>", 
                   ",", 
                   RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"Style\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"FileBaseName\"\>", ",", "\<\"[\"\>", 
                    ",", "\<\"file\"\>", ",", "\<\"]\"\>"}], "}"}], "]"}], 
                    ",", "\<\",\"\>", ",", "\<\"Red\"\>"}], "}"}], "]"}], 
                    ",", "\<\"]\"\>"}], "}"}], "]"}]}], "}"}], "]"}], 
                ",", "\<\"]\"\>"}], "}"}], "]"}], ",", "\<\";\"\>", 
             ",", "\<\"$Failed\"\>"}], "}"}], "]"}], ",", "\<\")\"\>"}], 
         "}"}], "]"}]}], "}"}], "]"}], ",", "\<\";\"\>"}], "}"}], 
  "]"}]], "Output",
 CellChangeTimes->{3.538751019178711*^9, 3.5391628386347656`*^9, 
  3.539878036426758*^9}]
}, Open  ]],

Cell[BoxData[
 RowBox[{"prn", "@", 
  RowBox[{"FullCodeFormat", "@", "boxes14"}]}]], "Input",
 CellChangeTimes->{{3.5387510373476562`*^9, 3.538751037484375*^9}, {
   3.539878043495117*^9, 3.539878053665039*^9}, 3.540387642310985*^9}],

Cell[BoxData[
 RowBox[{"\n", 
  RowBox[{
   RowBox[{
    RowBox[{"ClearAll", "[", "getVersionSince", "]"}], ";"}], "\n", 
   RowBox[{
    RowBox[{
     StyleBox[
      RowBox[{"getVersionSince", "::", "fail"}], "MessageName"], "=", "\n", 
     "\t", "\"\<Unable to extract version information for function `1`\>\""}],
     ";"}], "\n", 
   RowBox[{
    RowBox[{
     RowBox[{"getVersionSince", "[", 
      RowBox[{"file_String", "?", "FileExistsQ"}], "]"}], ":=", "\n", "\t", 
     RowBox[{"With", "[", 
      RowBox[{
       RowBox[{"{", 
        RowBox[{"nb", "=", 
         RowBox[{"NotebookOpen", "[", 
          RowBox[{"file", ",", 
           RowBox[{"Visible", "\[Rule]", "False"}]}], "]"}]}], "}"}], ",", 
       "\t", "\t", "\n", "\t", "\t", 
       RowBox[{
        RowBox[{"With", "[", "\n", "\t", "\t", 
         RowBox[{
          RowBox[{"{", "\n", "\t", "\t", "\t", 
           RowBox[{"res", "=", "\n", "\t", "\t", "\t", "\t", 
            RowBox[{
            "Cases", "[", "\t", "\t", "\t", "\t", "\t", "\n", "\t", "\t", 
             "\t", "\t", "\t", 
             RowBox[{
              RowBox[{"NotebookGet", "[", "nb", "]"}], ",", "\n", "\t", "\t", 
              "\t", "\t", "\t", 
              RowBox[{
               RowBox[{"Cell", "[", 
                RowBox[{"s_String", ",", "\"\<History\>\"", ",", "___"}], 
                "]"}], "\[RuleDelayed]", "\n", "\t", "\t", "\t", "\t", "\t", 
               "\t", 
               RowBox[{
               "StringCases", "[", "\t", "\t", "\t", "\t", "\t", "\t", "\t", 
                "\n", "\t", "\t", "\t", "\t", "\t", "\t", "\t", 
                RowBox[{
                 RowBox[{"StringTrim", "[", "s", "]"}], ",", "\n", "\t", "\t",
                  "\t", "\t", "\t", "\t", "\t", 
                 RowBox[{
                 "{", "\t", "\t", "\t", "\t", "\t", "\t", "\t", "\t", "\t", 
                  "\t", "\t", "\t", "\t", "\t", "\t", "\t", "\n", "\t", "\t", 
                  "\t", "\t", "\t", "\t", "\t", "\t", 
                  RowBox[{
                   RowBox[{
                    RowBox[{
                    "\"\<New in\>\"", "\n", "\t", "\t", "\t", "\t", "\t", 
                    "\t", "\t", "\t", "~~", "\n", "\t", "\t", "\t", "\t", 
                    "\t", "\t", "\t", "\t", 
                    RowBox[{"Whitespace", "|", "\"\<\>\""}], "\n", "\t", "\t",
                     "\t", "\t", "\t", "\t", "\t", "\t", "~~", "\n", "\t", 
                    "\t", "\t", "\t", "\t", "\t", "\t", "\t", 
                    RowBox[{"d", ":", 
                    RowBox[{"(", 
                    RowBox[{
                    RowBox[{"(", 
                    RowBox[{"DigitCharacter", "|", "\"\<.\>\""}], ")"}], 
                    ".."}], ")"}]}], "\n", "\t", "\t", "\t", "\t", "\t", "\t",
                     "\t", "\t", "~~", "\n", "\t", "\t", "\t", "\t", "\t", 
                    "\t", "\t", "\t", "__", "\n", "\t", "\t", "\t", "\t", 
                    "\t", "\t", "\t", "\t", "~~", "\n", "\t", "\t", "\t", 
                    "\t", "\t", "\t", "\t", "\t", "\"\<Last modified in\>\"", 
                    "\n", "\t", "\t", "\t", "\t", "\t", "\t", "\t", "\t", "~~",
                     "\n", "\t", "\t", "\t", "\t", "\t", "\t", "\t", "\t", 
                    RowBox[{"Whitespace", "|", "\"\<\>\""}], "\n", "\t", "\t",
                     "\t", "\t", "\t", "\t", "\t", "\t", "~~", "\n", "\t", 
                    "\t", "\t", "\t", "\t", "\t", "\t", "\t", 
                    RowBox[{"m", ":", 
                    RowBox[{"(", 
                    RowBox[{
                    RowBox[{"(", 
                    RowBox[{"DigitCharacter", "|", "\"\<.\>\""}], ")"}], 
                    ".."}], ")"}]}]}], "\[RuleDelayed]", "\n", "\t", "\t", 
                    "\t", "\t", "\t", "\t", "\t", "\t", "\t", 
                    RowBox[{"{", 
                    RowBox[{"d", ",", "m"}], "}"}]}], ",", "\t", "\t", "\t", 
                   "\t", "\t", "\t", "\t", "\t", "\n", "\t", "\t", "\t", "\t",
                    "\t", "\t", "\t", "\t", 
                   RowBox[{
                    RowBox[{
                    "\"\<New in\>\"", "\n", "\t", "\t", "\t", "\t", "\t", 
                    "\t", "\t", "\t", "~~", "\n", "\t", "\t", "\t", "\t", 
                    "\t", "\t", "\t", "\t", 
                    RowBox[{"Whitespace", "|", "\"\<\>\""}], "\n", "\t", "\t",
                     "\t", "\t", "\t", "\t", "\t", "\t", "~~", "\n", "\t", 
                    "\t", "\t", "\t", "\t", "\t", "\t", "\t", 
                    RowBox[{"d", ":", 
                    RowBox[{"(", 
                    RowBox[{
                    RowBox[{"(", 
                    RowBox[{"DigitCharacter", "|", "\"\<.\>\""}], ")"}], 
                    ".."}], ")"}]}]}], "\[RuleDelayed]", "\n", "\t", "\t", 
                    "\t", "\t", "\t", "\t", "\t", "\t", "\t", "d"}]}], "\n", 
                  "\t", "\t", "\t", "\t", "\t", "\t", "\t", "}"}]}], "\n", 
                "\t", "\t", "\t", "\t", "\t", "\t", "]"}]}], ",", "\n", "\t", 
              "\t", "\t", "\t", "\t", "\[Infinity]"}], "\n", "\t", "\t", "\t",
              "\t", "]"}]}], "\n", "\t", "\t", "}"}], ",", "\n", "\t", "\t", 
          "\t", 
          RowBox[{
           RowBox[{"NotebookClose", "[", "nb", "]"}], ";", 
           RowBox[{
            RowBox[{"First", "[", "res", "]"}], "/;", 
            RowBox[{"res", "=!=", 
             RowBox[{"{", "}"}]}]}]}]}], "\n", "\t", "\t", "]"}], "\n", "\t", 
        "\t", "/;", "\n", "\t", "\t", 
        RowBox[{"nb", "=!=", "$Failed"}]}]}], "\n", "\t", "]"}]}], ";"}], 
   "\n", 
   RowBox[{
    RowBox[{
     RowBox[{"getVersionSince", "[", 
      RowBox[{"file_String", "?", "FileExistsQ"}], "]"}], ":=", "\n", "\t", 
     RowBox[{"(", "\t", "\t", "\n", "\t", "\t", 
      RowBox[{
       RowBox[{"Message", "[", "\t", "\t", "\t", "\n", 
        RowBox[{
         StyleBox[
          RowBox[{"\t", "\t", "\t", 
           RowBox[{"getVersionSince", "::", "fail"}]}], "MessageName"], ",", 
         "\n", "\t", "\t", "\t", 
         RowBox[{"Style", "[", 
          RowBox[{
           RowBox[{"FileBaseName", "[", "file", "]"}], ",", "Red"}], "]"}]}], 
        "\n", "\t", "\t", "]"}], ";", "\n", "\t", "\t", "$Failed"}], "\n", 
      "\t", ")"}]}], ";"}]}]}]], "Input",
 GeneratedCell->True,
 CellAutoOverwrite->True,
 CellChangeTimes->{3.539878045595703*^9}],

Cell[BoxData[
 RowBox[{"prn", "@", 
  RowBox[{"FullCodeFormatCompact", "@", "boxes14"}]}]], "Input",
 CellChangeTimes->{{3.5398780624160156`*^9, 3.5398780635058594`*^9}, 
   3.540387642353996*^9}],

Cell[BoxData[
 RowBox[{"\n", 
  RowBox[{
   RowBox[{
    RowBox[{"ClearAll", "[", "getVersionSince", "]"}], ";"}], "\n", 
   RowBox[{
    RowBox[{
     StyleBox[
      RowBox[{"getVersionSince", "::", "fail"}], "MessageName"], "=", "\n", 
     "\t", "\"\<Unable to extract version information for function `1`\>\""}],
     ";"}], "\n", 
   RowBox[{
    RowBox[{
     RowBox[{"getVersionSince", "[", 
      RowBox[{"file_String", "?", "FileExistsQ"}], "]"}], ":=", "\n", "\t", 
     RowBox[{"With", "[", 
      RowBox[{
       RowBox[{"{", 
        RowBox[{"nb", "=", 
         RowBox[{"NotebookOpen", "[", 
          RowBox[{"file", ",", 
           RowBox[{"Visible", "\[Rule]", "False"}]}], "]"}]}], "}"}], ",", 
       "\t", "\t", "\n", "\t", "\t", 
       RowBox[{
        RowBox[{"With", "[", "\n", "\t", "\t", 
         RowBox[{
          RowBox[{"{", "\n", "\t", "\t", "\t", 
           RowBox[{"res", "=", "\n", "\t", "\t", "\t", "\t", 
            RowBox[{
            "Cases", "[", "\t", "\t", "\t", "\t", "\t", "\n", "\t", "\t", 
             "\t", "\t", "\t", 
             RowBox[{
              RowBox[{"NotebookGet", "[", "nb", "]"}], ",", "\n", "\t", "\t", 
              "\t", "\t", "\t", 
              RowBox[{
               RowBox[{"Cell", "[", 
                RowBox[{"s_String", ",", "\"\<History\>\"", ",", "___"}], 
                "]"}], "\[RuleDelayed]", "\n", "\t", "\t", "\t", "\t", "\t", 
               "\t", 
               RowBox[{
               "StringCases", "[", "\t", "\t", "\t", "\t", "\t", "\t", "\t", 
                "\n", "\t", "\t", "\t", "\t", "\t", "\t", "\t", 
                RowBox[{
                 RowBox[{"StringTrim", "[", "s", "]"}], ",", "\n", "\t", "\t",
                  "\t", "\t", "\t", "\t", "\t", 
                 RowBox[{
                 "{", "\t", "\t", "\t", "\t", "\t", "\t", "\t", "\t", "\t", 
                  "\t", "\t", "\t", "\t", "\t", "\t", "\t", "\n", "\t", "\t", 
                  "\t", "\t", "\t", "\t", "\t", "\t", 
                  RowBox[{
                   RowBox[{
                    RowBox[{
                    "\"\<New in\>\"", "\n", "\t", "\t", "\t", "\t", "\t", 
                    "\t", "\t", "\t", "~~", "\n", "\t", "\t", "\t", "\t", 
                    "\t", "\t", "\t", "\t", 
                    RowBox[{"Whitespace", "|", "\"\<\>\""}], "\n", "\t", "\t",
                     "\t", "\t", "\t", "\t", "\t", "\t", "~~", "\n", "\t", 
                    "\t", "\t", "\t", "\t", "\t", "\t", "\t", 
                    RowBox[{"d", ":", 
                    RowBox[{"(", 
                    RowBox[{
                    RowBox[{"(", 
                    RowBox[{"DigitCharacter", "|", "\"\<.\>\""}], ")"}], 
                    ".."}], ")"}]}], "\n", "\t", "\t", "\t", "\t", "\t", "\t",
                     "\t", "\t", "~~", "\n", "\t", "\t", "\t", "\t", "\t", 
                    "\t", "\t", "\t", "__", "\n", "\t", "\t", "\t", "\t", 
                    "\t", "\t", "\t", "\t", "~~", "\n", "\t", "\t", "\t", 
                    "\t", "\t", "\t", "\t", "\t", "\"\<Last modified in\>\"", 
                    "\n", "\t", "\t", "\t", "\t", "\t", "\t", "\t", "\t", "~~",
                     "\n", "\t", "\t", "\t", "\t", "\t", "\t", "\t", "\t", 
                    RowBox[{"Whitespace", "|", "\"\<\>\""}], "\n", "\t", "\t",
                     "\t", "\t", "\t", "\t", "\t", "\t", "~~", "\n", "\t", 
                    "\t", "\t", "\t", "\t", "\t", "\t", "\t", 
                    RowBox[{"m", ":", 
                    RowBox[{"(", 
                    RowBox[{
                    RowBox[{"(", 
                    RowBox[{"DigitCharacter", "|", "\"\<.\>\""}], ")"}], 
                    ".."}], ")"}]}]}], "\[RuleDelayed]", "\n", "\t", "\t", 
                    "\t", "\t", "\t", "\t", "\t", "\t", "\t", 
                    RowBox[{"{", 
                    RowBox[{"d", ",", "m"}], "}"}]}], ",", "\t", "\t", "\t", 
                   "\t", "\t", "\t", "\t", "\t", "\n", "\t", "\t", "\t", "\t",
                    "\t", "\t", "\t", "\t", 
                   RowBox[{
                    RowBox[{
                    "\"\<New in\>\"", "\n", "\t", "\t", "\t", "\t", "\t", 
                    "\t", "\t", "\t", "~~", "\n", "\t", "\t", "\t", "\t", 
                    "\t", "\t", "\t", "\t", 
                    RowBox[{"Whitespace", "|", "\"\<\>\""}], "\n", "\t", "\t",
                     "\t", "\t", "\t", "\t", "\t", "\t", "~~", "\n", "\t", 
                    "\t", "\t", "\t", "\t", "\t", "\t", "\t", 
                    RowBox[{"d", ":", 
                    RowBox[{"(", 
                    RowBox[{
                    RowBox[{"(", 
                    RowBox[{"DigitCharacter", "|", "\"\<.\>\""}], ")"}], 
                    ".."}], ")"}]}]}], "\[RuleDelayed]", "\n", "\t", "\t", 
                    "\t", "\t", "\t", "\t", "\t", "\t", "\t", "d"}]}], 
                  "}"}]}], "]"}]}], ",", "\n", "\t", "\t", "\t", "\t", "\t", 
              "\[Infinity]"}], "]"}]}], "}"}], ",", "\n", "\t", "\t", "\t", 
          RowBox[{
           RowBox[{"NotebookClose", "[", "nb", "]"}], ";", 
           RowBox[{
            RowBox[{"First", "[", "res", "]"}], "/;", 
            RowBox[{"res", "=!=", 
             RowBox[{"{", "}"}]}]}]}]}], "]"}], "\n", "\t", "\t", "/;", "\n", 
        "\t", "\t", 
        RowBox[{"nb", "=!=", "$Failed"}]}]}], "]"}]}], ";"}], "\n", 
   RowBox[{
    RowBox[{
     RowBox[{"getVersionSince", "[", 
      RowBox[{"file_String", "?", "FileExistsQ"}], "]"}], ":=", "\n", "\t", 
     RowBox[{"(", "\t", "\t", "\n", "\t", "\t", 
      RowBox[{
       RowBox[{"Message", "[", "\t", "\t", "\t", "\n", 
        RowBox[{
         StyleBox[
          RowBox[{"\t", "\t", "\t", 
           RowBox[{"getVersionSince", "::", "fail"}]}], "MessageName"], ",", 
         "\n", "\t", "\t", "\t", 
         RowBox[{"Style", "[", 
          RowBox[{
           RowBox[{"FileBaseName", "[", "file", "]"}], ",", "Red"}], "]"}]}], 
        "]"}], ";", "\n", "\t", "\t", "$Failed"}], ")"}]}], 
    ";"}]}]}]], "Input",
 GeneratedCell->True,
 CellAutoOverwrite->True,
 CellChangeTimes->{3.5398780641884766`*^9}]
}, Closed]],

Cell[CellGroupData[{

Cell["Example13", "Subsubsection",
 CellChangeTimes->{{3.5391688407617188`*^9, 3.539168841951172*^9}, 
   3.54040158041075*^9}],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"boxes15", " ", "=", " ", 
  RowBox[{"MakeBoxes", "[", "\[IndentingNewLine]", 
   RowBox[{
    RowBox[{"SetAttributes", "[", 
     RowBox[{"withTransforms", ",", "HoldAll"}], "]"}], ";", "\n", 
    RowBox[{
     RowBox[{"withTransforms", "[", "code_", "]"}], ":=", 
     RowBox[{"Block", "[", 
      RowBox[{
       RowBox[{"{", 
        RowBox[{
         RowBox[{"kx", "=", 
          RowBox[{"k", "*", 
           RowBox[{"Sin", "[", "a", "]"}], "*", 
           RowBox[{"Cos", "[", "b", "]"}]}]}], ",", 
         RowBox[{"ky", "=", 
          RowBox[{"k", "*", 
           RowBox[{"Sin", "[", "a", "]"}], "*", 
           RowBox[{"Sin", "[", "b", "]"}]}]}], ",", 
         RowBox[{"kz", "=", 
          RowBox[{"k", "*", 
           RowBox[{"Cos", "[", "b", "]"}]}]}]}], "}"}], ",", "code"}], 
      "]"}]}]}], "\[IndentingNewLine]", "]"}]}]], "Input",
 CellChangeTimes->{{3.5387540619248047`*^9, 3.538754103453125*^9}}],

Cell[BoxData[
 RowBox[{"RowBox", "[", 
  RowBox[{"{", 
   RowBox[{
    RowBox[{"RowBox", "[", 
     RowBox[{"{", 
      RowBox[{"\<\"SetAttributes\"\>", ",", "\<\"[\"\>", ",", 
       RowBox[{"RowBox", "[", 
        RowBox[{"{", 
         RowBox[{"\<\"withTransforms\"\>", ",", "\<\",\"\>", 
          ",", "\<\"HoldAll\"\>"}], "}"}], "]"}], ",", "\<\"]\"\>"}], "}"}], 
     "]"}], ",", "\<\";\"\>", ",", 
    RowBox[{"RowBox", "[", 
     RowBox[{"{", 
      RowBox[{
       RowBox[{"RowBox", "[", 
        RowBox[{"{", 
         RowBox[{"\<\"withTransforms\"\>", ",", "\<\"[\"\>", 
          ",", "\<\"code_\"\>", ",", "\<\"]\"\>"}], "}"}], "]"}], 
       ",", "\<\":=\"\>", ",", 
       RowBox[{"RowBox", "[", 
        RowBox[{"{", 
         RowBox[{"\<\"Block\"\>", ",", "\<\"[\"\>", ",", 
          RowBox[{"RowBox", "[", 
           RowBox[{"{", 
            RowBox[{
             RowBox[{"RowBox", "[", 
              RowBox[{"{", 
               RowBox[{"\<\"{\"\>", ",", 
                RowBox[{"RowBox", "[", 
                 RowBox[{"{", 
                  RowBox[{
                   RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"kx\"\>", ",", "\<\"=\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"k\"\>", ",", "\<\" \"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"Sin\"\>", ",", "\<\"[\"\>", ",", "\<\"a\"\>",
                     ",", "\<\"]\"\>"}], "}"}], "]"}], ",", "\<\" \"\>", ",", 
                    
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"Cos\"\>", ",", "\<\"[\"\>", ",", "\<\"b\"\>",
                     ",", "\<\"]\"\>"}], "}"}], "]"}]}], "}"}], "]"}]}], 
                    "}"}], "]"}], ",", "\<\",\"\>", ",", 
                   RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"ky\"\>", ",", "\<\"=\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"k\"\>", ",", "\<\" \"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"Sin\"\>", ",", "\<\"[\"\>", ",", "\<\"a\"\>",
                     ",", "\<\"]\"\>"}], "}"}], "]"}], ",", "\<\" \"\>", ",", 
                    
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"Sin\"\>", ",", "\<\"[\"\>", ",", "\<\"b\"\>",
                     ",", "\<\"]\"\>"}], "}"}], "]"}]}], "}"}], "]"}]}], 
                    "}"}], "]"}], ",", "\<\",\"\>", ",", 
                   RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"kz\"\>", ",", "\<\"=\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"k\"\>", ",", "\<\" \"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"Cos\"\>", ",", "\<\"[\"\>", ",", "\<\"b\"\>",
                     ",", "\<\"]\"\>"}], "}"}], "]"}]}], "}"}], "]"}]}], 
                    "}"}], "]"}]}], "}"}], "]"}], ",", "\<\"}\"\>"}], "}"}], 
              "]"}], ",", "\<\",\"\>", ",", "\<\"code\"\>"}], "}"}], "]"}], 
          ",", "\<\"]\"\>"}], "}"}], "]"}]}], "}"}], "]"}]}], "}"}], 
  "]"}]], "Output",
 CellChangeTimes->{3.538754079517578*^9, 3.5387541294404297`*^9, 
  3.5391688527265625`*^9, 3.5398781187685547`*^9}]
}, Open  ]],

Cell[BoxData[
 RowBox[{"prn", "@", 
  RowBox[{"FullCodeFormat", "@", "boxes15"}]}]], "Input",
 CellChangeTimes->{{3.5387541415302734`*^9, 3.5387541415927734`*^9}, {
   3.539878123010742*^9, 3.5398781357529297`*^9}, 3.540387642395915*^9}],

Cell[BoxData[
 RowBox[{"\n", 
  RowBox[{
   RowBox[{
    RowBox[{"SetAttributes", "[", 
     RowBox[{"withTransforms", ",", "HoldAll"}], "]"}], ";"}], "\n", 
   RowBox[{
    RowBox[{"withTransforms", "[", "code_", "]"}], ":=", "\n", "\t", 
    RowBox[{"Block", "[", 
     RowBox[{
      RowBox[{"{", 
       RowBox[{
        RowBox[{"kx", "=", 
         RowBox[{"k", 
          RowBox[{"Sin", "[", "a", "]"}], 
          RowBox[{"Cos", "[", "b", "]"}]}]}], ",", 
        RowBox[{"ky", "=", 
         RowBox[{"k", 
          RowBox[{"Sin", "[", "a", "]"}], 
          RowBox[{"Sin", "[", "b", "]"}]}]}], ",", 
        RowBox[{"kz", "=", 
         RowBox[{"k", 
          RowBox[{"Cos", "[", "b", "]"}]}]}]}], "}"}], ",", "code"}], 
     "]"}]}]}]}]], "Input",
 GeneratedCell->True,
 CellAutoOverwrite->True,
 CellChangeTimes->{3.539878126083008*^9}],

Cell[BoxData[
 RowBox[{"prn", "@", 
  RowBox[{"FullCodeFormatCompact", "@", "boxes15"}]}]], "Input",
 CellChangeTimes->{{3.539878143977539*^9, 3.539878144973633*^9}, 
   3.540387642439325*^9}],

Cell[BoxData[
 RowBox[{"\n", 
  RowBox[{
   RowBox[{
    RowBox[{"SetAttributes", "[", 
     RowBox[{"withTransforms", ",", "HoldAll"}], "]"}], ";"}], "\n", 
   RowBox[{
    RowBox[{"withTransforms", "[", "code_", "]"}], ":=", "\n", "\t", 
    RowBox[{"Block", "[", 
     RowBox[{
      RowBox[{"{", 
       RowBox[{
        RowBox[{"kx", "=", 
         RowBox[{"k", 
          RowBox[{"Sin", "[", "a", "]"}], 
          RowBox[{"Cos", "[", "b", "]"}]}]}], ",", 
        RowBox[{"ky", "=", 
         RowBox[{"k", 
          RowBox[{"Sin", "[", "a", "]"}], 
          RowBox[{"Sin", "[", "b", "]"}]}]}], ",", 
        RowBox[{"kz", "=", 
         RowBox[{"k", 
          RowBox[{"Cos", "[", "b", "]"}]}]}]}], "}"}], ",", "code"}], 
     "]"}]}]}]}]], "Input",
 GeneratedCell->True,
 CellAutoOverwrite->True,
 CellChangeTimes->{3.539878145555664*^9}]
}, Closed]],

Cell[CellGroupData[{

Cell["Example14", "Subsubsection",
 CellChangeTimes->{{3.5391688648632812`*^9, 3.539168865833008*^9}, 
   3.540401581081621*^9}],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"boxes16", " ", "=", " ", 
  RowBox[{"MakeBoxes", "[", "\[IndentingNewLine]", 
   RowBox[{
    RowBox[{"Clear", "[", "btComp", "]"}], ";", "\n", 
    RowBox[{"btComp", "=", 
     RowBox[{"Compile", "[", 
      RowBox[{
       RowBox[{"{", 
        RowBox[{"{", 
         RowBox[{"lst", ",", "_Integer", ",", "1"}], "}"}], "}"}], ",", 
       RowBox[{"Module", "[", 
        RowBox[{
         RowBox[{"{", 
          RowBox[{"refs", ",", "result", ",", 
           RowBox[{"endrefs", "=", 
            RowBox[{"{", "1", "}"}]}], ",", 
           RowBox[{"ends", "=", 
            RowBox[{"{", 
             RowBox[{"First", "@", "lst"}], "}"}]}], ",", 
           RowBox[{"len", "=", 
            RowBox[{"Length", "@", "lst"}]}], ",", 
           RowBox[{"n0", "=", "1"}], ",", 
           RowBox[{"n1", "=", "1"}], ",", 
           RowBox[{"i", "=", "1"}], ",", "n", ",", "e"}], "}"}], ",", 
         RowBox[{
          RowBox[{"refs", "=", 
           RowBox[{"result", "=", 
            RowBox[{"0", " ", "lst"}]}]}], ";", "\[IndentingNewLine]", 
          RowBox[{"For", "[", 
           RowBox[{
            RowBox[{"i", "=", "2"}], ",", 
            RowBox[{"i", "\[LessEqual]", "len"}], ",", 
            RowBox[{"i", "++"}], ",", 
            RowBox[{"Which", "[", 
             RowBox[{
              RowBox[{
               RowBox[{"lst", "[", 
                RowBox[{"[", "i", "]"}], "]"}], "<", 
               RowBox[{"First", "@", "ends"}]}], ",", 
              RowBox[{"(", 
               RowBox[{
                RowBox[{
                 RowBox[{"ends", "[", 
                  RowBox[{"[", "1", "]"}], "]"}], "=", 
                 RowBox[{"lst", "[", 
                  RowBox[{"[", "i", "]"}], "]"}]}], ";", 
                RowBox[{
                 RowBox[{"endrefs", "[", 
                  RowBox[{"[", "1", "]"}], "]"}], "=", "i"}], ";", 
                RowBox[{
                 RowBox[{"refs", "[", 
                  RowBox[{"[", "i", "]"}], "]"}], "=", "0"}]}], ")"}], ",", 
              RowBox[{
               RowBox[{"lst", "[", 
                RowBox[{"[", "i", "]"}], "]"}], ">", 
               RowBox[{"Last", "@", "ends"}]}], ",", 
              RowBox[{"(", 
               RowBox[{
                RowBox[{
                 RowBox[{"refs", "[", 
                  RowBox[{"[", "i", "]"}], "]"}], "=", 
                 RowBox[{"Last", "@", "endrefs"}]}], ";", 
                RowBox[{"AppendTo", "[", 
                 RowBox[{"ends", ",", 
                  RowBox[{"lst", "[", 
                   RowBox[{"[", "i", "]"}], "]"}]}], "]"}], ";", 
                RowBox[{"AppendTo", "[", 
                 RowBox[{"endrefs", ",", "i"}], "]"}]}], ")"}], ",", 
              RowBox[{
               RowBox[{"First", "@", "ends"}], "<", 
               RowBox[{"lst", "[", 
                RowBox[{"[", "i", "]"}], "]"}], "<", 
               RowBox[{"Last", "@", "ends"}]}], ",", 
              RowBox[{"(", 
               RowBox[{
                RowBox[{"n0", "=", "1"}], ";", 
                RowBox[{"n1", "=", 
                 RowBox[{"Length", "@", "ends"}]}], ";", 
                "\[IndentingNewLine]", 
                RowBox[{"While", "[", 
                 RowBox[{
                  RowBox[{
                   RowBox[{"n1", "-", "n0"}], ">", "1"}], ",", 
                  RowBox[{
                   RowBox[{"n", "=", 
                    RowBox[{"Floor", "[", 
                    RowBox[{
                    RowBox[{"(", 
                    RowBox[{"n0", "+", "n1"}], ")"}], "/", "2"}], "]"}]}], 
                   ";", "\[IndentingNewLine]", 
                   RowBox[{"If", "[", 
                    RowBox[{
                    RowBox[{
                    RowBox[{"ends", "[", 
                    RowBox[{"[", "n", "]"}], "]"}], "<", 
                    RowBox[{"lst", "[", 
                    RowBox[{"[", "i", "]"}], "]"}]}], ",", 
                    RowBox[{"n0", "=", "n"}], ",", 
                    RowBox[{"n1", "=", "n"}]}], "]"}]}]}], "]"}], ";", 
                "\[IndentingNewLine]", 
                RowBox[{
                 RowBox[{"ends", "[", 
                  RowBox[{"[", "n1", "]"}], "]"}], "=", 
                 RowBox[{"lst", "[", 
                  RowBox[{"[", "i", "]"}], "]"}]}], ";", 
                "\[IndentingNewLine]", 
                RowBox[{
                 RowBox[{"endrefs", "[", 
                  RowBox[{"[", "n1", "]"}], "]"}], "=", "i"}], ";", 
                "\[IndentingNewLine]", 
                RowBox[{
                 RowBox[{"refs", "[", 
                  RowBox[{"[", "i", "]"}], "]"}], "=", 
                 RowBox[{"endrefs", "[", 
                  RowBox[{"[", 
                   RowBox[{"n1", "-", "1"}], "]"}], "]"}]}]}], ")"}]}], 
             "]"}]}], "]"}], ";", "\[IndentingNewLine]", 
          RowBox[{"For", "[", 
           RowBox[{
            RowBox[{
             RowBox[{"i", "=", "1"}], ";", 
             RowBox[{"e", "=", 
              RowBox[{"Last", "@", "endrefs"}]}]}], ",", 
            RowBox[{"e", "\[NotEqual]", "0"}], ",", 
            RowBox[{"(", 
             RowBox[{
              RowBox[{"i", "++"}], ";", 
              RowBox[{"e", "=", 
               RowBox[{"refs", "[", 
                RowBox[{"[", "e", "]"}], "]"}]}]}], ")"}], ",", 
            RowBox[{
             RowBox[{"result", "[", 
              RowBox[{"[", "i", "]"}], "]"}], "=", 
             RowBox[{"lst", "[", 
              RowBox[{"[", "e", "]"}], "]"}]}]}], "]"}], ";", 
          "\[IndentingNewLine]", 
          RowBox[{"Reverse", "@", 
           RowBox[{"Take", "[", 
            RowBox[{"result", ",", 
             RowBox[{"i", "-", "1"}]}], "]"}]}]}]}], "]"}], ",", 
       RowBox[{"CompilationTarget", "\[Rule]", "\"\<C\>\""}]}], "]"}]}], 
    ";"}], "]"}]}]], "Input",
 CellChangeTimes->{{3.5387543758896484`*^9, 3.538754390944336*^9}}],

Cell[BoxData[
 RowBox[{"RowBox", "[", 
  RowBox[{"{", 
   RowBox[{
    RowBox[{"RowBox", "[", 
     RowBox[{"{", 
      RowBox[{"\<\"Clear\"\>", ",", "\<\"[\"\>", ",", "\<\"btComp\"\>", 
       ",", "\<\"]\"\>"}], "}"}], "]"}], ",", "\<\";\"\>", ",", 
    RowBox[{"RowBox", "[", 
     RowBox[{"{", 
      RowBox[{"\<\"btComp\"\>", ",", "\<\"=\"\>", ",", 
       RowBox[{"RowBox", "[", 
        RowBox[{"{", 
         RowBox[{"\<\"Compile\"\>", ",", "\<\"[\"\>", ",", 
          RowBox[{"RowBox", "[", 
           RowBox[{"{", 
            RowBox[{
             RowBox[{"RowBox", "[", 
              RowBox[{"{", 
               RowBox[{"\<\"{\"\>", ",", 
                RowBox[{"RowBox", "[", 
                 RowBox[{"{", 
                  RowBox[{"\<\"{\"\>", ",", 
                   RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"lst\"\>", ",", "\<\",\"\>", 
                    ",", "\<\"_Integer\"\>", ",", "\<\",\"\>", 
                    ",", "\<\"1\"\>"}], "}"}], "]"}], ",", "\<\"}\"\>"}], 
                  "}"}], "]"}], ",", "\<\"}\"\>"}], "}"}], "]"}], 
             ",", "\<\",\"\>", ",", 
             RowBox[{"RowBox", "[", 
              RowBox[{"{", 
               RowBox[{"\<\"Module\"\>", ",", "\<\"[\"\>", ",", 
                RowBox[{"RowBox", "[", 
                 RowBox[{"{", 
                  RowBox[{
                   RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"{\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"refs\"\>", ",", "\<\",\"\>", 
                    ",", "\<\"result\"\>", ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"endrefs\"\>", ",", "\<\"=\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"{\"\>", ",", "\<\"1\"\>", ",", "\<\"}\"\>"}],
                     "}"}], "]"}]}], "}"}], "]"}], ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"ends\"\>", ",", "\<\"=\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"{\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"First\"\>", ",", "\<\"[\"\>", 
                    ",", "\<\"lst\"\>", ",", "\<\"]\"\>"}], "}"}], "]"}], 
                    ",", "\<\"}\"\>"}], "}"}], "]"}]}], "}"}], "]"}], 
                    ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"len\"\>", ",", "\<\"=\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"Length\"\>", ",", "\<\"[\"\>", 
                    ",", "\<\"lst\"\>", ",", "\<\"]\"\>"}], "}"}], "]"}]}], 
                    "}"}], "]"}], ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"n0\"\>", ",", "\<\"=\"\>", 
                    ",", "\<\"1\"\>"}], "}"}], "]"}], ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"n1\"\>", ",", "\<\"=\"\>", 
                    ",", "\<\"1\"\>"}], "}"}], "]"}], ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"i\"\>", ",", "\<\"=\"\>", ",", "\<\"1\"\>"}],
                     "}"}], "]"}], ",", "\<\",\"\>", ",", "\<\"n\"\>", 
                    ",", "\<\",\"\>", ",", "\<\"e\"\>"}], "}"}], "]"}], 
                    ",", "\<\"}\"\>"}], "}"}], "]"}], ",", "\<\",\"\>", ",", 
                   RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"refs\"\>", ",", "\<\"=\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"result\"\>", ",", "\<\"=\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"0\"\>", ",", "\<\" \"\>", 
                    ",", "\<\"lst\"\>"}], "}"}], "]"}]}], "}"}], "]"}]}], 
                    "}"}], "]"}], ",", "\<\";\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"For\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"i\"\>", ",", "\<\"=\"\>", ",", "\<\"2\"\>"}],
                     "}"}], "]"}], ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"i\"\>", ",", "\<\"\[LessEqual]\"\>", 
                    ",", "\<\"len\"\>"}], "}"}], "]"}], ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"i\"\>", ",", "\<\"++\"\>"}], "}"}], "]"}], 
                    ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"Which\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"lst\"\>", 
                    ",", "\<\"\[LeftDoubleBracket]\"\>", ",", "\<\"i\"\>", 
                    ",", "\<\"\[RightDoubleBracket]\"\>"}], "}"}], "]"}], 
                    ",", "\<\"<\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"First\"\>", ",", "\<\"[\"\>", 
                    ",", "\<\"ends\"\>", ",", "\<\"]\"\>"}], "}"}], "]"}]}], 
                    "}"}], "]"}], ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"ends\"\>", 
                    ",", "\<\"\[LeftDoubleBracket]\"\>", ",", "\<\"1\"\>", 
                    ",", "\<\"\[RightDoubleBracket]\"\>"}], "}"}], "]"}], 
                    ",", "\<\"=\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"lst\"\>", 
                    ",", "\<\"\[LeftDoubleBracket]\"\>", ",", "\<\"i\"\>", 
                    ",", "\<\"\[RightDoubleBracket]\"\>"}], "}"}], "]"}]}], 
                    "}"}], "]"}], ",", "\<\";\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"endrefs\"\>", 
                    ",", "\<\"\[LeftDoubleBracket]\"\>", ",", "\<\"1\"\>", 
                    ",", "\<\"\[RightDoubleBracket]\"\>"}], "}"}], "]"}], 
                    ",", "\<\"=\"\>", ",", "\<\"i\"\>"}], "}"}], "]"}], 
                    ",", "\<\";\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"refs\"\>", 
                    ",", "\<\"\[LeftDoubleBracket]\"\>", ",", "\<\"i\"\>", 
                    ",", "\<\"\[RightDoubleBracket]\"\>"}], "}"}], "]"}], 
                    ",", "\<\"=\"\>", ",", "\<\"0\"\>"}], "}"}], "]"}]}], 
                    "}"}], "]"}], ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"lst\"\>", 
                    ",", "\<\"\[LeftDoubleBracket]\"\>", ",", "\<\"i\"\>", 
                    ",", "\<\"\[RightDoubleBracket]\"\>"}], "}"}], "]"}], 
                    ",", "\<\">\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"Last\"\>", ",", "\<\"[\"\>", 
                    ",", "\<\"ends\"\>", ",", "\<\"]\"\>"}], "}"}], "]"}]}], 
                    "}"}], "]"}], ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"refs\"\>", 
                    ",", "\<\"\[LeftDoubleBracket]\"\>", ",", "\<\"i\"\>", 
                    ",", "\<\"\[RightDoubleBracket]\"\>"}], "}"}], "]"}], 
                    ",", "\<\"=\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"Last\"\>", ",", "\<\"[\"\>", 
                    ",", "\<\"endrefs\"\>", ",", "\<\"]\"\>"}], "}"}], 
                    "]"}]}], "}"}], "]"}], ",", "\<\";\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"AppendTo\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"ends\"\>", ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"lst\"\>", 
                    ",", "\<\"\[LeftDoubleBracket]\"\>", ",", "\<\"i\"\>", 
                    ",", "\<\"\[RightDoubleBracket]\"\>"}], "}"}], "]"}]}], 
                    "}"}], "]"}], ",", "\<\"]\"\>"}], "}"}], "]"}], 
                    ",", "\<\";\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"AppendTo\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"endrefs\"\>", ",", "\<\",\"\>", 
                    ",", "\<\"i\"\>"}], "}"}], "]"}], ",", "\<\"]\"\>"}], 
                    "}"}], "]"}]}], "}"}], "]"}], ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"First\"\>", ",", "\<\"[\"\>", 
                    ",", "\<\"ends\"\>", ",", "\<\"]\"\>"}], "}"}], "]"}], 
                    ",", "\<\"<\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"lst\"\>", 
                    ",", "\<\"\[LeftDoubleBracket]\"\>", ",", "\<\"i\"\>", 
                    ",", "\<\"\[RightDoubleBracket]\"\>"}], "}"}], "]"}], 
                    ",", "\<\"<\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"Last\"\>", ",", "\<\"[\"\>", 
                    ",", "\<\"ends\"\>", ",", "\<\"]\"\>"}], "}"}], "]"}]}], 
                    "}"}], "]"}], ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"n0\"\>", ",", "\<\"=\"\>", 
                    ",", "\<\"1\"\>"}], "}"}], "]"}], ",", "\<\";\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"n1\"\>", ",", "\<\"=\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"Length\"\>", ",", "\<\"[\"\>", 
                    ",", "\<\"ends\"\>", ",", "\<\"]\"\>"}], "}"}], "]"}]}], 
                    "}"}], "]"}], ",", "\<\";\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"While\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"n1\"\>", ",", "\<\"-\"\>", 
                    ",", "\<\"n0\"\>"}], "}"}], "]"}], ",", "\<\">\"\>", 
                    ",", "\<\"1\"\>"}], "}"}], "]"}], ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"n\"\>", ",", "\<\"=\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"Floor\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"FractionBox", "[", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"n0\"\>", ",", "\<\"+\"\>", 
                    ",", "\<\"n1\"\>"}], "}"}], "]"}], ",", "\<\"2\"\>"}], 
                    "]"}], ",", "\<\"]\"\>"}], "}"}], "]"}]}], "}"}], "]"}], 
                    ",", "\<\";\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"If\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"ends\"\>", 
                    ",", "\<\"\[LeftDoubleBracket]\"\>", ",", "\<\"n\"\>", 
                    ",", "\<\"\[RightDoubleBracket]\"\>"}], "}"}], "]"}], 
                    ",", "\<\"<\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"lst\"\>", 
                    ",", "\<\"\[LeftDoubleBracket]\"\>", ",", "\<\"i\"\>", 
                    ",", "\<\"\[RightDoubleBracket]\"\>"}], "}"}], "]"}]}], 
                    "}"}], "]"}], ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"n0\"\>", ",", "\<\"=\"\>", 
                    ",", "\<\"n\"\>"}], "}"}], "]"}], ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"n1\"\>", ",", "\<\"=\"\>", 
                    ",", "\<\"n\"\>"}], "}"}], "]"}]}], "}"}], "]"}], 
                    ",", "\<\"]\"\>"}], "}"}], "]"}]}], "}"}], "]"}]}], "}"}],
                     "]"}], ",", "\<\"]\"\>"}], "}"}], "]"}], 
                    ",", "\<\";\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"ends\"\>", 
                    ",", "\<\"\[LeftDoubleBracket]\"\>", ",", "\<\"n1\"\>", 
                    ",", "\<\"\[RightDoubleBracket]\"\>"}], "}"}], "]"}], 
                    ",", "\<\"=\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"lst\"\>", 
                    ",", "\<\"\[LeftDoubleBracket]\"\>", ",", "\<\"i\"\>", 
                    ",", "\<\"\[RightDoubleBracket]\"\>"}], "}"}], "]"}]}], 
                    "}"}], "]"}], ",", "\<\";\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"endrefs\"\>", 
                    ",", "\<\"\[LeftDoubleBracket]\"\>", ",", "\<\"n1\"\>", 
                    ",", "\<\"\[RightDoubleBracket]\"\>"}], "}"}], "]"}], 
                    ",", "\<\"=\"\>", ",", "\<\"i\"\>"}], "}"}], "]"}], 
                    ",", "\<\";\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"refs\"\>", 
                    ",", "\<\"\[LeftDoubleBracket]\"\>", ",", "\<\"i\"\>", 
                    ",", "\<\"\[RightDoubleBracket]\"\>"}], "}"}], "]"}], 
                    ",", "\<\"=\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"endrefs\"\>", 
                    ",", "\<\"\[LeftDoubleBracket]\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"n1\"\>", ",", "\<\"-\"\>", 
                    ",", "\<\"1\"\>"}], "}"}], "]"}], 
                    ",", "\<\"\[RightDoubleBracket]\"\>"}], "}"}], "]"}]}], 
                    "}"}], "]"}]}], "}"}], "]"}]}], "}"}], "]"}], 
                    ",", "\<\"]\"\>"}], "}"}], "]"}]}], "}"}], "]"}], 
                    ",", "\<\"]\"\>"}], "}"}], "]"}], ",", "\<\";\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"For\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"i\"\>", ",", "\<\"=\"\>", ",", "\<\"1\"\>"}],
                     "}"}], "]"}], ",", "\<\";\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"e\"\>", ",", "\<\"=\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"Last\"\>", ",", "\<\"[\"\>", 
                    ",", "\<\"endrefs\"\>", ",", "\<\"]\"\>"}], "}"}], 
                    "]"}]}], "}"}], "]"}]}], "}"}], "]"}], ",", "\<\",\"\>", 
                    ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"e\"\>", ",", "\<\"\[NotEqual]\"\>", 
                    ",", "\<\"0\"\>"}], "}"}], "]"}], ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"i\"\>", ",", "\<\"++\"\>"}], "}"}], "]"}], 
                    ",", "\<\";\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"e\"\>", ",", "\<\"=\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"refs\"\>", 
                    ",", "\<\"\[LeftDoubleBracket]\"\>", ",", "\<\"e\"\>", 
                    ",", "\<\"\[RightDoubleBracket]\"\>"}], "}"}], "]"}]}], 
                    "}"}], "]"}]}], "}"}], "]"}], ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"result\"\>", 
                    ",", "\<\"\[LeftDoubleBracket]\"\>", ",", "\<\"i\"\>", 
                    ",", "\<\"\[RightDoubleBracket]\"\>"}], "}"}], "]"}], 
                    ",", "\<\"=\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"lst\"\>", 
                    ",", "\<\"\[LeftDoubleBracket]\"\>", ",", "\<\"e\"\>", 
                    ",", "\<\"\[RightDoubleBracket]\"\>"}], "}"}], "]"}]}], 
                    "}"}], "]"}]}], "}"}], "]"}], ",", "\<\"]\"\>"}], "}"}], 
                    "]"}], ",", "\<\";\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"Reverse\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"Take\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"result\"\>", ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"i\"\>", ",", "\<\"-\"\>", ",", "\<\"1\"\>"}],
                     "}"}], "]"}]}], "}"}], "]"}], ",", "\<\"]\"\>"}], "}"}], 
                    "]"}], ",", "\<\"]\"\>"}], "}"}], "]"}]}], "}"}], "]"}]}],
                   "}"}], "]"}], ",", "\<\"]\"\>"}], "}"}], "]"}], 
             ",", "\<\",\"\>", ",", 
             RowBox[{"RowBox", "[", 
              RowBox[{"{", 
               
               RowBox[{"\<\"CompilationTarget\"\>", ",", "\<\"\[Rule]\"\>", 
                ",", "\<\"\\\"C\\\"\"\>"}], "}"}], "]"}]}], "}"}], "]"}], 
          ",", "\<\"]\"\>"}], "}"}], "]"}]}], "}"}], "]"}], 
    ",", "\<\";\"\>"}], "}"}], "]"}]], "Output",
 CellChangeTimes->{3.538754392522461*^9, 3.5391688706972656`*^9, 
  3.539878157338867*^9}]
}, Open  ]],

Cell[BoxData[
 RowBox[{
  RowBox[{"prn", "@", 
   RowBox[{"FullCodeFormat", "@", "boxes16"}]}], 
  "\[IndentingNewLine]"}]], "Input",
 CellChangeTimes->{{3.5387544005166016`*^9, 3.538754400669922*^9}, {
   3.539878162709961*^9, 3.539878164348633*^9}, 3.540387642485047*^9}],

Cell[BoxData[
 RowBox[{"\n", 
  RowBox[{
   RowBox[{
    RowBox[{"Clear", "[", "btComp", "]"}], ";"}], "\n", 
   RowBox[{
    RowBox[{"btComp", "=", "\n", "\t", 
     RowBox[{"Compile", "[", "\t", "\t", "\n", "\t", "\t", 
      RowBox[{
       RowBox[{"{", 
        RowBox[{"{", 
         RowBox[{"lst", ",", "_Integer", ",", "1"}], "}"}], "}"}], ",", "\n", 
       "\t", "\t", 
       RowBox[{"Module", "[", "\n", "\t", "\t", 
        RowBox[{
         RowBox[{"{", "\t", "\t", "\t", "\n", "\t", "\t", "\t", 
          RowBox[{
          "refs", ",", "\n", "\t", "\t", "\t", "result", ",", "\n", "\t", 
           "\t", "\t", 
           RowBox[{"endrefs", "=", 
            RowBox[{"{", "1", "}"}]}], ",", "\n", "\t", "\t", "\t", 
           RowBox[{"ends", "=", 
            RowBox[{"{", 
             RowBox[{"First", "[", "lst", "]"}], "}"}]}], ",", "\n", "\t", 
           "\t", "\t", 
           RowBox[{"len", "=", 
            RowBox[{"Length", "[", "lst", "]"}]}], ",", "\n", "\t", "\t", 
           "\t", 
           RowBox[{"n0", "=", "1"}], ",", "\n", "\t", "\t", "\t", 
           RowBox[{"n1", "=", "1"}], ",", "\n", "\t", "\t", "\t", 
           RowBox[{"i", "=", "1"}], ",", "\n", "\t", "\t", "\t", "n", ",", 
           "\n", "\t", "\t", "\t", "e"}], "\n", "\t", "\t", "}"}], ",", "\t", 
         "\t", "\t", "\n", "\t", "\t", "\t", 
         RowBox[{
          RowBox[{"refs", "=", 
           RowBox[{"result", "=", 
            RowBox[{"0", "lst"}]}]}], ";", "\n", "\t", "\t", "\t", 
          RowBox[{
          "For", "[", "\t", "\t", "\t", "\t", "\n", "\t", "\t", "\t", "\t", 
           RowBox[{
            RowBox[{"i", "=", "2"}], ",", "\n", "\t", "\t", "\t", "\t", 
            RowBox[{"i", "\[LessEqual]", "len"}], ",", "\n", "\t", "\t", "\t",
             "\t", 
            RowBox[{"i", "++"}], ",", "\n", "\t", "\t", "\t", "\t", 
            RowBox[{
            "Which", "[", "\t", "\t", "\t", "\t", "\t", "\n", "\t", "\t", 
             "\t", "\t", "\t", 
             RowBox[{
              RowBox[{
               RowBox[{
               "lst", "\[LeftDoubleBracket]", "i", "\[RightDoubleBracket]"}], 
               "<", 
               RowBox[{"First", "[", "ends", "]"}]}], ",", "\n", "\t", "\t", 
              "\t", "\t", "\t", 
              RowBox[{
               RowBox[{
                RowBox[{
                "ends", "\[LeftDoubleBracket]", "1", 
                 "\[RightDoubleBracket]"}], "=", 
                RowBox[{
                "lst", "\[LeftDoubleBracket]", "i", 
                 "\[RightDoubleBracket]"}]}], ";", 
               RowBox[{
                RowBox[{
                "endrefs", "\[LeftDoubleBracket]", "1", 
                 "\[RightDoubleBracket]"}], "=", "i"}], ";", 
               RowBox[{
                RowBox[{
                "refs", "\[LeftDoubleBracket]", "i", 
                 "\[RightDoubleBracket]"}], "=", "0"}]}], ",", "\n", "\t", 
              "\t", "\t", "\t", "\t", 
              RowBox[{
               RowBox[{
               "lst", "\[LeftDoubleBracket]", "i", "\[RightDoubleBracket]"}], 
               ">", 
               RowBox[{"Last", "[", "ends", "]"}]}], ",", "\t", "\t", "\t", 
              "\t", "\t", "\n", "\t", "\t", "\t", "\t", "\t", 
              RowBox[{
               RowBox[{
                RowBox[{
                "refs", "\[LeftDoubleBracket]", "i", 
                 "\[RightDoubleBracket]"}], "=", 
                RowBox[{"Last", "[", "endrefs", "]"}]}], ";", "\n", "\t", 
               "\t", "\t", "\t", "\t", 
               RowBox[{"AppendTo", "[", 
                RowBox[{"ends", ",", 
                 RowBox[{
                 "lst", "\[LeftDoubleBracket]", "i", 
                  "\[RightDoubleBracket]"}]}], "]"}], ";", "\n", "\t", "\t", 
               "\t", "\t", "\t", 
               RowBox[{"AppendTo", "[", 
                RowBox[{"endrefs", ",", "i"}], "]"}]}], ",", "\n", "\t", "\t",
               "\t", "\t", "\t", 
              RowBox[{
               RowBox[{"First", "[", "ends", "]"}], "<", 
               RowBox[{
               "lst", "\[LeftDoubleBracket]", "i", "\[RightDoubleBracket]"}], 
               "<", 
               RowBox[{"Last", "[", "ends", "]"}]}], ",", "\t", "\t", "\t", 
              "\t", "\t", "\n", "\t", "\t", "\t", "\t", "\t", 
              RowBox[{
               RowBox[{"n0", "=", "1"}], ";", "\n", "\t", "\t", "\t", "\t", 
               "\t", 
               RowBox[{"n1", "=", 
                RowBox[{"Length", "[", "ends", "]"}]}], ";", "\n", "\t", "\t",
                "\t", "\t", "\t", 
               RowBox[{
               "While", "[", "\t", "\t", "\t", "\t", "\t", "\t", "\n", "\t", 
                "\t", "\t", "\t", "\t", "\t", 
                RowBox[{
                 RowBox[{
                  RowBox[{"n1", "-", "n0"}], ">", "1"}], ",", "\n", "\t", 
                 "\t", "\t", "\t", "\t", "\t", 
                 RowBox[{
                  RowBox[{"n", "=", 
                   RowBox[{"Floor", "[", 
                    FractionBox[
                    RowBox[{"n0", "+", "n1"}], "2"], "]"}]}], ";", 
                  RowBox[{"If", "[", 
                   RowBox[{
                    RowBox[{
                    RowBox[{
                    "ends", "\[LeftDoubleBracket]", "n", 
                    "\[RightDoubleBracket]"}], "<", 
                    RowBox[{
                    "lst", "\[LeftDoubleBracket]", "i", 
                    "\[RightDoubleBracket]"}]}], ",", 
                    RowBox[{"n0", "=", "n"}], ",", 
                    RowBox[{"n1", "=", "n"}]}], "]"}]}]}], "\n", "\t", "\t", 
                "\t", "\t", "\t", "]"}], ";", "\n", "\t", "\t", "\t", "\t", 
               "\t", 
               RowBox[{
                RowBox[{
                "ends", "\[LeftDoubleBracket]", "n1", 
                 "\[RightDoubleBracket]"}], "=", 
                RowBox[{
                "lst", "\[LeftDoubleBracket]", "i", 
                 "\[RightDoubleBracket]"}]}], ";", "\n", "\t", "\t", "\t", 
               "\t", "\t", 
               RowBox[{
                RowBox[{
                "endrefs", "\[LeftDoubleBracket]", "n1", 
                 "\[RightDoubleBracket]"}], "=", "i"}], ";", "\n", "\t", "\t",
                "\t", "\t", "\t", 
               RowBox[{
                RowBox[{
                "refs", "\[LeftDoubleBracket]", "i", 
                 "\[RightDoubleBracket]"}], "=", 
                RowBox[{"endrefs", "\[LeftDoubleBracket]", 
                 RowBox[{"n1", "-", "1"}], "\[RightDoubleBracket]"}]}]}]}], 
             "\n", "\t", "\t", "\t", "\t", "]"}]}], "\n", "\t", "\t", "\t", 
           "]"}], ";", "\n", "\t", "\t", "\t", 
          RowBox[{"For", "[", "\n", "\t", "\t", "\t", "\t", 
           RowBox[{
            RowBox[{
             RowBox[{"i", "=", "1"}], ";", 
             RowBox[{"e", "=", 
              RowBox[{"Last", "[", "endrefs", "]"}]}]}], ",", 
            RowBox[{"e", "\[NotEqual]", "0"}], ",", 
            RowBox[{
             RowBox[{"i", "++"}], ";", 
             RowBox[{"e", "=", 
              RowBox[{
              "refs", "\[LeftDoubleBracket]", "e", 
               "\[RightDoubleBracket]"}]}]}], ",", 
            RowBox[{
             RowBox[{
             "result", "\[LeftDoubleBracket]", "i", "\[RightDoubleBracket]"}],
              "=", 
             RowBox[{
             "lst", "\[LeftDoubleBracket]", "e", 
              "\[RightDoubleBracket]"}]}]}], "\n", "\t", "\t", "\t", "]"}], 
          ";", "\n", "\t", "\t", "\t", 
          RowBox[{"Reverse", "[", 
           RowBox[{"Take", "[", 
            RowBox[{"result", ",", 
             RowBox[{"i", "-", "1"}]}], "]"}], "]"}]}]}], "\n", "\t", "\t", 
        "]"}], ",", "\n", "\t", "\t", 
       RowBox[{"CompilationTarget", "\[Rule]", "\"\<C\>\""}]}], "\n", "\t", 
      "]"}]}], ";"}]}]}]], "Input",
 GeneratedCell->True,
 CellAutoOverwrite->True,
 CellChangeTimes->{3.5398781650527344`*^9}],

Cell[BoxData[
 RowBox[{
  RowBox[{"prn", "@", 
   RowBox[{"FullCodeFormatCompact", "@", "boxes16"}]}], 
  "\[IndentingNewLine]"}]], "Input",
 CellChangeTimes->{{3.539878187088867*^9, 3.539878188232422*^9}, 
   3.540387642527621*^9}],

Cell[BoxData[
 RowBox[{"\n", 
  RowBox[{
   RowBox[{
    RowBox[{"Clear", "[", "btComp", "]"}], ";"}], "\n", 
   RowBox[{
    RowBox[{"btComp", "=", "\n", "\t", 
     RowBox[{"Compile", "[", "\t", "\t", "\n", "\t", "\t", 
      RowBox[{
       RowBox[{"{", 
        RowBox[{"{", 
         RowBox[{"lst", ",", "_Integer", ",", "1"}], "}"}], "}"}], ",", "\n", 
       "\t", "\t", 
       RowBox[{"Module", "[", "\n", "\t", "\t", 
        RowBox[{
         RowBox[{"{", "\t", "\t", "\t", "\n", "\t", "\t", "\t", 
          RowBox[{
          "refs", ",", "\n", "\t", "\t", "\t", "result", ",", "\n", "\t", 
           "\t", "\t", 
           RowBox[{"endrefs", "=", 
            RowBox[{"{", "1", "}"}]}], ",", "\n", "\t", "\t", "\t", 
           RowBox[{"ends", "=", 
            RowBox[{"{", 
             RowBox[{"First", "[", "lst", "]"}], "}"}]}], ",", "\n", "\t", 
           "\t", "\t", 
           RowBox[{"len", "=", 
            RowBox[{"Length", "[", "lst", "]"}]}], ",", "\n", "\t", "\t", 
           "\t", 
           RowBox[{"n0", "=", "1"}], ",", "\n", "\t", "\t", "\t", 
           RowBox[{"n1", "=", "1"}], ",", "\n", "\t", "\t", "\t", 
           RowBox[{"i", "=", "1"}], ",", "\n", "\t", "\t", "\t", "n", ",", 
           "\n", "\t", "\t", "\t", "e"}], "}"}], ",", "\t", "\t", "\t", "\n", 
         "\t", "\t", "\t", 
         RowBox[{
          RowBox[{"refs", "=", 
           RowBox[{"result", "=", 
            RowBox[{"0", "lst"}]}]}], ";", "\n", "\t", "\t", "\t", 
          RowBox[{
          "For", "[", "\t", "\t", "\t", "\t", "\n", "\t", "\t", "\t", "\t", 
           RowBox[{
            RowBox[{"i", "=", "2"}], ",", "\n", "\t", "\t", "\t", "\t", 
            RowBox[{"i", "\[LessEqual]", "len"}], ",", "\n", "\t", "\t", "\t",
             "\t", 
            RowBox[{"i", "++"}], ",", "\n", "\t", "\t", "\t", "\t", 
            RowBox[{
            "Which", "[", "\t", "\t", "\t", "\t", "\t", "\n", "\t", "\t", 
             "\t", "\t", "\t", 
             RowBox[{
              RowBox[{
               RowBox[{
               "lst", "\[LeftDoubleBracket]", "i", "\[RightDoubleBracket]"}], 
               "<", 
               RowBox[{"First", "[", "ends", "]"}]}], ",", "\n", "\t", "\t", 
              "\t", "\t", "\t", 
              RowBox[{
               RowBox[{
                RowBox[{
                "ends", "\[LeftDoubleBracket]", "1", 
                 "\[RightDoubleBracket]"}], "=", 
                RowBox[{
                "lst", "\[LeftDoubleBracket]", "i", 
                 "\[RightDoubleBracket]"}]}], ";", 
               RowBox[{
                RowBox[{
                "endrefs", "\[LeftDoubleBracket]", "1", 
                 "\[RightDoubleBracket]"}], "=", "i"}], ";", 
               RowBox[{
                RowBox[{
                "refs", "\[LeftDoubleBracket]", "i", 
                 "\[RightDoubleBracket]"}], "=", "0"}]}], ",", "\n", "\t", 
              "\t", "\t", "\t", "\t", 
              RowBox[{
               RowBox[{
               "lst", "\[LeftDoubleBracket]", "i", "\[RightDoubleBracket]"}], 
               ">", 
               RowBox[{"Last", "[", "ends", "]"}]}], ",", "\t", "\t", "\t", 
              "\t", "\t", "\n", "\t", "\t", "\t", "\t", "\t", 
              RowBox[{
               RowBox[{
                RowBox[{
                "refs", "\[LeftDoubleBracket]", "i", 
                 "\[RightDoubleBracket]"}], "=", 
                RowBox[{"Last", "[", "endrefs", "]"}]}], ";", "\n", "\t", 
               "\t", "\t", "\t", "\t", 
               RowBox[{"AppendTo", "[", 
                RowBox[{"ends", ",", 
                 RowBox[{
                 "lst", "\[LeftDoubleBracket]", "i", 
                  "\[RightDoubleBracket]"}]}], "]"}], ";", "\n", "\t", "\t", 
               "\t", "\t", "\t", 
               RowBox[{"AppendTo", "[", 
                RowBox[{"endrefs", ",", "i"}], "]"}]}], ",", "\n", "\t", "\t",
               "\t", "\t", "\t", 
              RowBox[{
               RowBox[{"First", "[", "ends", "]"}], "<", 
               RowBox[{
               "lst", "\[LeftDoubleBracket]", "i", "\[RightDoubleBracket]"}], 
               "<", 
               RowBox[{"Last", "[", "ends", "]"}]}], ",", "\t", "\t", "\t", 
              "\t", "\t", "\n", "\t", "\t", "\t", "\t", "\t", 
              RowBox[{
               RowBox[{"n0", "=", "1"}], ";", "\n", "\t", "\t", "\t", "\t", 
               "\t", 
               RowBox[{"n1", "=", 
                RowBox[{"Length", "[", "ends", "]"}]}], ";", "\n", "\t", "\t",
                "\t", "\t", "\t", 
               RowBox[{
               "While", "[", "\t", "\t", "\t", "\t", "\t", "\t", "\n", "\t", 
                "\t", "\t", "\t", "\t", "\t", 
                RowBox[{
                 RowBox[{
                  RowBox[{"n1", "-", "n0"}], ">", "1"}], ",", "\n", "\t", 
                 "\t", "\t", "\t", "\t", "\t", 
                 RowBox[{
                  RowBox[{"n", "=", 
                   RowBox[{"Floor", "[", 
                    FractionBox[
                    RowBox[{"n0", "+", "n1"}], "2"], "]"}]}], ";", 
                  RowBox[{"If", "[", 
                   RowBox[{
                    RowBox[{
                    RowBox[{
                    "ends", "\[LeftDoubleBracket]", "n", 
                    "\[RightDoubleBracket]"}], "<", 
                    RowBox[{
                    "lst", "\[LeftDoubleBracket]", "i", 
                    "\[RightDoubleBracket]"}]}], ",", 
                    RowBox[{"n0", "=", "n"}], ",", 
                    RowBox[{"n1", "=", "n"}]}], "]"}]}]}], "]"}], ";", "\n", 
               "\t", "\t", "\t", "\t", "\t", 
               RowBox[{
                RowBox[{
                "ends", "\[LeftDoubleBracket]", "n1", 
                 "\[RightDoubleBracket]"}], "=", 
                RowBox[{
                "lst", "\[LeftDoubleBracket]", "i", 
                 "\[RightDoubleBracket]"}]}], ";", "\n", "\t", "\t", "\t", 
               "\t", "\t", 
               RowBox[{
                RowBox[{
                "endrefs", "\[LeftDoubleBracket]", "n1", 
                 "\[RightDoubleBracket]"}], "=", "i"}], ";", "\n", "\t", "\t",
                "\t", "\t", "\t", 
               RowBox[{
                RowBox[{
                "refs", "\[LeftDoubleBracket]", "i", 
                 "\[RightDoubleBracket]"}], "=", 
                RowBox[{"endrefs", "\[LeftDoubleBracket]", 
                 RowBox[{"n1", "-", "1"}], "\[RightDoubleBracket]"}]}]}]}], 
             "]"}]}], "]"}], ";", "\n", "\t", "\t", "\t", 
          RowBox[{"For", "[", "\n", "\t", "\t", "\t", "\t", 
           RowBox[{
            RowBox[{
             RowBox[{"i", "=", "1"}], ";", 
             RowBox[{"e", "=", 
              RowBox[{"Last", "[", "endrefs", "]"}]}]}], ",", 
            RowBox[{"e", "\[NotEqual]", "0"}], ",", 
            RowBox[{
             RowBox[{"i", "++"}], ";", 
             RowBox[{"e", "=", 
              RowBox[{
              "refs", "\[LeftDoubleBracket]", "e", 
               "\[RightDoubleBracket]"}]}]}], ",", 
            RowBox[{
             RowBox[{
             "result", "\[LeftDoubleBracket]", "i", "\[RightDoubleBracket]"}],
              "=", 
             RowBox[{
             "lst", "\[LeftDoubleBracket]", "e", 
              "\[RightDoubleBracket]"}]}]}], "]"}], ";", "\n", "\t", "\t", 
          "\t", 
          RowBox[{"Reverse", "[", 
           RowBox[{"Take", "[", 
            RowBox[{"result", ",", 
             RowBox[{"i", "-", "1"}]}], "]"}], "]"}]}]}], "]"}], ",", "\n", 
       "\t", "\t", 
       RowBox[{"CompilationTarget", "\[Rule]", "\"\<C\>\""}]}], "]"}]}], 
    ";"}]}]}]], "Input",
 GeneratedCell->True,
 CellAutoOverwrite->True,
 CellChangeTimes->{3.539878189296875*^9}]
}, Closed]],

Cell[CellGroupData[{

Cell["Example15", "Subsubsection",
 CellChangeTimes->{{3.539168895564453*^9, 3.5391688965654297`*^9}, 
   3.540401581679175*^9}],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"boxes17", " ", "=", " ", 
  RowBox[{"MakeBoxes", "[", 
   RowBox[{
    RowBox[{"ClearAll", "[", "profile", "]"}], ";", "\n", 
    RowBox[{"SetAttributes", "[", 
     RowBox[{"profile", ",", "HoldAll"}], "]"}], ";", "\n", 
    RowBox[{
     RowBox[{"profile", "[", "code_", "]"}], ":=", 
     RowBox[{"Block", "[", 
      RowBox[{
       RowBox[{"{", 
        RowBox[{
         RowBox[{"$totalTime", "=", "0"}], ",", "t", ",", "res", ",", "time", 
         ",", "exclude"}], "}"}], ",", 
       RowBox[{
        RowBox[{"SetAttributes", "[", 
         RowBox[{
          RowBox[{"{", 
           RowBox[{"time", ",", "exclude"}], "}"}], ",", "HoldAll"}], "]"}], 
        ";", "\[IndentingNewLine]", 
        RowBox[{
         RowBox[{"exclude", "[", "cd_", "]"}], ":=", 
         RowBox[{"(", 
          RowBox[{
           RowBox[{"t", "=", 
            RowBox[{"AbsoluteTime", "[", "]"}]}], ";", 
           RowBox[{"res", "=", "cd"}], ";", 
           RowBox[{"$totalTime", "-=", 
            RowBox[{
             RowBox[{"AbsoluteTime", "[", "]"}], "-", "t"}]}], ";", "res"}], 
          ")"}]}], ";", "\[IndentingNewLine]", 
        RowBox[{
         RowBox[{"time", "[", "cd_", "]"}], ":=", 
         RowBox[{"(", 
          RowBox[{
           RowBox[{"t", "=", 
            RowBox[{"AbsoluteTime", "[", "]"}]}], ";", 
           RowBox[{"res", "=", "cd"}], ";", 
           RowBox[{"$totalTime", "+=", 
            RowBox[{
             RowBox[{"AbsoluteTime", "[", "]"}], "-", "t"}]}], ";", "res"}], 
          ")"}]}], ";", "\[IndentingNewLine]", 
        RowBox[{"{", 
         RowBox[{"code", ",", "$totalTime"}], "}"}]}]}], "]"}]}], ";"}], 
   "]"}]}]], "Input",
 CellChangeTimes->{{3.538756009676758*^9, 3.538756022095703*^9}}],

Cell[BoxData[
 RowBox[{"RowBox", "[", 
  RowBox[{"{", 
   RowBox[{
    RowBox[{"RowBox", "[", 
     RowBox[{"{", 
      RowBox[{"\<\"ClearAll\"\>", ",", "\<\"[\"\>", ",", "\<\"profile\"\>", 
       ",", "\<\"]\"\>"}], "}"}], "]"}], ",", "\<\";\"\>", ",", 
    RowBox[{"RowBox", "[", 
     RowBox[{"{", 
      RowBox[{"\<\"SetAttributes\"\>", ",", "\<\"[\"\>", ",", 
       RowBox[{"RowBox", "[", 
        RowBox[{"{", 
         RowBox[{"\<\"profile\"\>", ",", "\<\",\"\>", 
          ",", "\<\"HoldAll\"\>"}], "}"}], "]"}], ",", "\<\"]\"\>"}], "}"}], 
     "]"}], ",", "\<\";\"\>", ",", 
    RowBox[{"RowBox", "[", 
     RowBox[{"{", 
      RowBox[{
       RowBox[{"RowBox", "[", 
        RowBox[{"{", 
         RowBox[{"\<\"profile\"\>", ",", "\<\"[\"\>", ",", "\<\"code_\"\>", 
          ",", "\<\"]\"\>"}], "}"}], "]"}], ",", "\<\":=\"\>", ",", 
       RowBox[{"RowBox", "[", 
        RowBox[{"{", 
         RowBox[{"\<\"Block\"\>", ",", "\<\"[\"\>", ",", 
          RowBox[{"RowBox", "[", 
           RowBox[{"{", 
            RowBox[{
             RowBox[{"RowBox", "[", 
              RowBox[{"{", 
               RowBox[{"\<\"{\"\>", ",", 
                RowBox[{"RowBox", "[", 
                 RowBox[{"{", 
                  RowBox[{
                   RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"$totalTime\"\>", ",", "\<\"=\"\>", 
                    ",", "\<\"0\"\>"}], "}"}], "]"}], ",", "\<\",\"\>", 
                   ",", "\<\"t\"\>", ",", "\<\",\"\>", ",", "\<\"res\"\>", 
                   ",", "\<\",\"\>", ",", "\<\"time\"\>", ",", "\<\",\"\>", 
                   ",", "\<\"exclude\"\>"}], "}"}], "]"}], ",", "\<\"}\"\>"}],
                "}"}], "]"}], ",", "\<\",\"\>", ",", 
             RowBox[{"RowBox", "[", 
              RowBox[{"{", 
               RowBox[{
                RowBox[{"RowBox", "[", 
                 RowBox[{"{", 
                  RowBox[{"\<\"SetAttributes\"\>", ",", "\<\"[\"\>", ",", 
                   RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"{\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"time\"\>", ",", "\<\",\"\>", 
                    ",", "\<\"exclude\"\>"}], "}"}], "]"}], 
                    ",", "\<\"}\"\>"}], "}"}], "]"}], ",", "\<\",\"\>", 
                    ",", "\<\"HoldAll\"\>"}], "}"}], "]"}], 
                   ",", "\<\"]\"\>"}], "}"}], "]"}], ",", "\<\";\"\>", ",", 
                RowBox[{"RowBox", "[", 
                 RowBox[{"{", 
                  RowBox[{
                   RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"exclude\"\>", ",", "\<\"[\"\>", 
                    ",", "\<\"cd_\"\>", ",", "\<\"]\"\>"}], "}"}], "]"}], 
                   ",", "\<\":=\"\>", ",", 
                   RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"(\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"t\"\>", ",", "\<\"=\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"AbsoluteTime\"\>", ",", "\<\"[\"\>", 
                    ",", "\<\"]\"\>"}], "}"}], "]"}]}], "}"}], "]"}], 
                    ",", "\<\";\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"res\"\>", ",", "\<\"=\"\>", 
                    ",", "\<\"cd\"\>"}], "}"}], "]"}], ",", "\<\";\"\>", ",", 
                    
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"$totalTime\"\>", ",", "\<\"-=\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"AbsoluteTime\"\>", ",", "\<\"[\"\>", 
                    ",", "\<\"]\"\>"}], "}"}], "]"}], ",", "\<\"-\"\>", 
                    ",", "\<\"t\"\>"}], "}"}], "]"}]}], "}"}], "]"}], 
                    ",", "\<\";\"\>", ",", "\<\"res\"\>"}], "}"}], "]"}], 
                    ",", "\<\")\"\>"}], "}"}], "]"}]}], "}"}], "]"}], 
                ",", "\<\";\"\>", ",", 
                RowBox[{"RowBox", "[", 
                 RowBox[{"{", 
                  RowBox[{
                   RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"time\"\>", ",", "\<\"[\"\>", 
                    ",", "\<\"cd_\"\>", ",", "\<\"]\"\>"}], "}"}], "]"}], 
                   ",", "\<\":=\"\>", ",", 
                   RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"(\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"t\"\>", ",", "\<\"=\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"AbsoluteTime\"\>", ",", "\<\"[\"\>", 
                    ",", "\<\"]\"\>"}], "}"}], "]"}]}], "}"}], "]"}], 
                    ",", "\<\";\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"res\"\>", ",", "\<\"=\"\>", 
                    ",", "\<\"cd\"\>"}], "}"}], "]"}], ",", "\<\";\"\>", ",", 
                    
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"$totalTime\"\>", ",", "\<\"+=\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"AbsoluteTime\"\>", ",", "\<\"[\"\>", 
                    ",", "\<\"]\"\>"}], "}"}], "]"}], ",", "\<\"-\"\>", 
                    ",", "\<\"t\"\>"}], "}"}], "]"}]}], "}"}], "]"}], 
                    ",", "\<\";\"\>", ",", "\<\"res\"\>"}], "}"}], "]"}], 
                    ",", "\<\")\"\>"}], "}"}], "]"}]}], "}"}], "]"}], 
                ",", "\<\";\"\>", ",", 
                RowBox[{"RowBox", "[", 
                 RowBox[{"{", 
                  RowBox[{"\<\"{\"\>", ",", 
                   RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"code\"\>", ",", "\<\",\"\>", 
                    ",", "\<\"$totalTime\"\>"}], "}"}], "]"}], 
                   ",", "\<\"}\"\>"}], "}"}], "]"}]}], "}"}], "]"}]}], "}"}], 
           "]"}], ",", "\<\"]\"\>"}], "}"}], "]"}]}], "}"}], "]"}], 
    ",", "\<\";\"\>"}], "}"}], "]"}]], "Output",
 CellChangeTimes->{3.538756022915039*^9, 3.5391691116279297`*^9, 
  3.539878217501953*^9}]
}, Open  ]],

Cell[BoxData[
 RowBox[{"prn", "@", 
  RowBox[{"FullCodeFormat", "@", "boxes17"}]}]], "Input",
 CellChangeTimes->{{3.5387560335507812`*^9, 3.5387560336210938`*^9}, {
   3.539878221745117*^9, 3.5398782271689453`*^9}, 3.540387642574453*^9}],

Cell[BoxData[
 RowBox[{"\n", 
  RowBox[{
   RowBox[{
    RowBox[{"ClearAll", "[", "profile", "]"}], ";"}], "\n", 
   RowBox[{
    RowBox[{"SetAttributes", "[", 
     RowBox[{"profile", ",", "HoldAll"}], "]"}], ";"}], "\n", 
   RowBox[{
    RowBox[{
     RowBox[{"profile", "[", "code_", "]"}], ":=", "\n", "\t", 
     RowBox[{"Block", "[", 
      RowBox[{
       RowBox[{"{", 
        RowBox[{
         RowBox[{"$totalTime", "=", "0"}], ",", "t", ",", "res", ",", "time", 
         ",", "exclude"}], "}"}], ",", "\t", "\t", "\n", "\t", "\t", 
       RowBox[{
        RowBox[{"SetAttributes", "[", 
         RowBox[{
          RowBox[{"{", 
           RowBox[{"time", ",", "exclude"}], "}"}], ",", "HoldAll"}], "]"}], 
        ";", "\n", "\t", "\t", 
        RowBox[{
         RowBox[{"exclude", "[", "cd_", "]"}], ":=", "\n", "\t", "\t", "\t", 
         RowBox[{"(", 
          RowBox[{
           RowBox[{"t", "=", 
            RowBox[{"AbsoluteTime", "[", "]"}]}], ";", 
           RowBox[{"res", "=", "cd"}], ";", 
           RowBox[{"$totalTime", "-=", 
            RowBox[{
             RowBox[{"AbsoluteTime", "[", "]"}], "-", "t"}]}], ";", "res"}], 
          ")"}]}], ";", "\n", "\t", "\t", 
        RowBox[{
         RowBox[{"time", "[", "cd_", "]"}], ":=", "\n", "\t", "\t", "\t", 
         RowBox[{"(", 
          RowBox[{
           RowBox[{"t", "=", 
            RowBox[{"AbsoluteTime", "[", "]"}]}], ";", 
           RowBox[{"res", "=", "cd"}], ";", 
           RowBox[{"$totalTime", "+=", 
            RowBox[{
             RowBox[{"AbsoluteTime", "[", "]"}], "-", "t"}]}], ";", "res"}], 
          ")"}]}], ";", "\n", "\t", "\t", 
        RowBox[{"{", 
         RowBox[{"code", ",", "$totalTime"}], "}"}]}]}], "\n", "\t", "]"}]}], 
    ";"}]}]}]], "Input",
 GeneratedCell->True,
 CellAutoOverwrite->True,
 CellChangeTimes->{3.539878224060547*^9}],

Cell[BoxData[
 RowBox[{"prn", "@", 
  RowBox[{"FullCodeFormatCompact", "@", "boxes17"}]}]], "Input",
 CellChangeTimes->{{3.5398782346464844`*^9, 3.539878235732422*^9}, 
   3.540387642616562*^9}],

Cell[BoxData[
 RowBox[{"\n", 
  RowBox[{
   RowBox[{
    RowBox[{"ClearAll", "[", "profile", "]"}], ";"}], "\n", 
   RowBox[{
    RowBox[{"SetAttributes", "[", 
     RowBox[{"profile", ",", "HoldAll"}], "]"}], ";"}], "\n", 
   RowBox[{
    RowBox[{
     RowBox[{"profile", "[", "code_", "]"}], ":=", "\n", "\t", 
     RowBox[{"Block", "[", 
      RowBox[{
       RowBox[{"{", 
        RowBox[{
         RowBox[{"$totalTime", "=", "0"}], ",", "t", ",", "res", ",", "time", 
         ",", "exclude"}], "}"}], ",", "\t", "\t", "\n", "\t", "\t", 
       RowBox[{
        RowBox[{"SetAttributes", "[", 
         RowBox[{
          RowBox[{"{", 
           RowBox[{"time", ",", "exclude"}], "}"}], ",", "HoldAll"}], "]"}], 
        ";", "\n", "\t", "\t", 
        RowBox[{
         RowBox[{"exclude", "[", "cd_", "]"}], ":=", "\n", "\t", "\t", "\t", 
         RowBox[{"(", 
          RowBox[{
           RowBox[{"t", "=", 
            RowBox[{"AbsoluteTime", "[", "]"}]}], ";", 
           RowBox[{"res", "=", "cd"}], ";", 
           RowBox[{"$totalTime", "-=", 
            RowBox[{
             RowBox[{"AbsoluteTime", "[", "]"}], "-", "t"}]}], ";", "res"}], 
          ")"}]}], ";", "\n", "\t", "\t", 
        RowBox[{
         RowBox[{"time", "[", "cd_", "]"}], ":=", "\n", "\t", "\t", "\t", 
         RowBox[{"(", 
          RowBox[{
           RowBox[{"t", "=", 
            RowBox[{"AbsoluteTime", "[", "]"}]}], ";", 
           RowBox[{"res", "=", "cd"}], ";", 
           RowBox[{"$totalTime", "+=", 
            RowBox[{
             RowBox[{"AbsoluteTime", "[", "]"}], "-", "t"}]}], ";", "res"}], 
          ")"}]}], ";", "\n", "\t", "\t", 
        RowBox[{"{", 
         RowBox[{"code", ",", "$totalTime"}], "}"}]}]}], "]"}]}], 
    ";"}]}]}]], "Input",
 GeneratedCell->True,
 CellAutoOverwrite->True,
 CellChangeTimes->{3.539878236421875*^9}]
}, Closed]],

Cell[CellGroupData[{

Cell["Example16", "Subsubsection",
 CellChangeTimes->{{3.539169128163086*^9, 3.5391691295546875`*^9}, {
   3.539199029300453*^9, 3.539199031102211*^9}, 3.540401582399951*^9}],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"boxes18", " ", "=", " ", 
  RowBox[{"MakeBoxes", "[", 
   RowBox[{"(*", 
    RowBox[{"Note", ":", 
     RowBox[{
     "there", " ", "may", " ", "be", " ", "other", " ", "rules", " ", "added",
       " ", "here"}]}], "*)"}], 
   RowBox[{
    RowBox[{"ClearAll", "[", "lex", "]"}], ";", "\n", 
    RowBox[{"lex", "/:", 
     RowBox[{"SetDelayed", "[", 
      RowBox[{
       RowBox[{"lex", "@", "def_"}], ",", "rhs_"}], "]"}], ":=", 
     RowBox[{"SetDelayed", "@@", 
      RowBox[{"Prepend", "[", 
       RowBox[{
        RowBox[{
         RowBox[{"Hold", "[", "rhs", "]"}], "/.", 
         RowBox[{"Module", "\[Rule]", "removingModule"}]}], ",", 
        RowBox[{"Unevaluated", "[", "def", "]"}]}], "]"}]}]}], ";"}], 
   "]"}]}]], "Input",
 CellChangeTimes->{{3.538758232651367*^9, 3.5387582399804688`*^9}}],

Cell[BoxData[
 RowBox[{"RowBox", "[", 
  RowBox[{"{", 
   RowBox[{
    RowBox[{"RowBox", "[", 
     RowBox[{"{", 
      RowBox[{"\<\"ClearAll\"\>", ",", "\<\"[\"\>", ",", "\<\"lex\"\>", 
       ",", "\<\"]\"\>"}], "}"}], "]"}], ",", "\<\";\"\>", ",", 
    RowBox[{"RowBox", "[", 
     RowBox[{"{", 
      RowBox[{"\<\"lex\"\>", ",", "\<\"/:\"\>", ",", 
       RowBox[{"RowBox", "[", 
        RowBox[{"{", 
         RowBox[{"\<\"(\"\>", ",", 
          RowBox[{"RowBox", "[", 
           RowBox[{"{", 
            RowBox[{
             RowBox[{"RowBox", "[", 
              RowBox[{"{", 
               
               RowBox[{"\<\"lex\"\>", ",", "\<\"[\"\>", ",", "\<\"def_\"\>", 
                ",", "\<\"]\"\>"}], "}"}], "]"}], ",", "\<\":=\"\>", 
             ",", "\<\"rhs_\"\>"}], "}"}], "]"}], ",", "\<\")\"\>"}], "}"}], 
        "]"}], ",", "\<\":=\"\>", ",", 
       RowBox[{"RowBox", "[", 
        RowBox[{"{", 
         RowBox[{"\<\"SetDelayed\"\>", ",", "\<\"@@\"\>", ",", 
          RowBox[{"RowBox", "[", 
           RowBox[{"{", 
            RowBox[{"\<\"Prepend\"\>", ",", "\<\"[\"\>", ",", 
             RowBox[{"RowBox", "[", 
              RowBox[{"{", 
               RowBox[{
                RowBox[{"RowBox", "[", 
                 RowBox[{"{", 
                  RowBox[{
                   RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"Hold\"\>", ",", "\<\"[\"\>", 
                    ",", "\<\"rhs\"\>", ",", "\<\"]\"\>"}], "}"}], "]"}], 
                   ",", "\<\"/.\"\>", ",", "\<\"\[InvisibleSpace]\"\>", ",", 
                   RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"Module\"\>", ",", "\<\"\[Rule]\"\>", 
                    ",", "\<\"removingModule\"\>"}], "}"}], "]"}]}], "}"}], 
                 "]"}], ",", "\<\",\"\>", ",", 
                RowBox[{"RowBox", "[", 
                 RowBox[{"{", 
                  
                  RowBox[{"\<\"Unevaluated\"\>", ",", "\<\"[\"\>", 
                   ",", "\<\"def\"\>", ",", "\<\"]\"\>"}], "}"}], "]"}]}], 
               "}"}], "]"}], ",", "\<\"]\"\>"}], "}"}], "]"}]}], "}"}], 
        "]"}]}], "}"}], "]"}], ",", "\<\";\"\>"}], "}"}], "]"}]], "Output",
 CellChangeTimes->{3.5387582405185547`*^9, 3.5391906311884766`*^9, 
  3.5398782516621094`*^9}]
}, Open  ]],

Cell[BoxData[
 RowBox[{"prn", "@", 
  RowBox[{"FullCodeFormat", "@", "boxes18"}]}]], "Input",
 CellChangeTimes->{{3.5387582497421875`*^9, 3.5387582497958984`*^9}, {
   3.539192000689453*^9, 3.5391920038740234`*^9}, {3.5398782627978516`*^9, 
   3.5398782681064453`*^9}, 3.54038764265948*^9}],

Cell[BoxData[
 RowBox[{"\n", 
  RowBox[{
   RowBox[{
    RowBox[{"ClearAll", "[", "lex", "]"}], ";"}], "\n", 
   RowBox[{
    RowBox[{"lex", "/:", 
     RowBox[{"(", 
      RowBox[{
       RowBox[{"lex", "[", "def_", "]"}], ":=", "\n", "\t", "rhs_"}], ")"}], ":=",
      "\n", "\t", 
     RowBox[{"SetDelayed", "@@", "\n", "\t", "\t", 
      RowBox[{"Prepend", "[", 
       RowBox[{
        RowBox[{
         RowBox[{"Hold", "[", "rhs", "]"}], "/.", "\[InvisibleSpace]", 
         RowBox[{"Module", "\[Rule]", "removingModule"}]}], ",", 
        RowBox[{"Unevaluated", "[", "def", "]"}]}], "]"}]}]}], 
    ";"}]}]}]], "Input",
 GeneratedCell->True,
 CellAutoOverwrite->True,
 CellChangeTimes->{3.5398782652910156`*^9}],

Cell[BoxData[
 RowBox[{"prn", "@", 
  RowBox[{"FullCodeFormatCompact", "@", "boxes18"}]}]], "Input",
 CellChangeTimes->{{3.5398782750722656`*^9, 3.5398782760908203`*^9}, 
   3.540387642701673*^9}],

Cell[BoxData[
 RowBox[{"\n", 
  RowBox[{
   RowBox[{
    RowBox[{"ClearAll", "[", "lex", "]"}], ";"}], "\n", 
   RowBox[{
    RowBox[{"lex", "/:", 
     RowBox[{"(", 
      RowBox[{
       RowBox[{"lex", "[", "def_", "]"}], ":=", "\n", "\t", "rhs_"}], ")"}], ":=",
      "\n", "\t", 
     RowBox[{"SetDelayed", "@@", "\n", "\t", "\t", 
      RowBox[{"Prepend", "[", 
       RowBox[{
        RowBox[{
         RowBox[{"Hold", "[", "rhs", "]"}], "/.", "\[InvisibleSpace]", 
         RowBox[{"Module", "\[Rule]", "removingModule"}]}], ",", 
        RowBox[{"Unevaluated", "[", "def", "]"}]}], "]"}]}]}], 
    ";"}]}]}]], "Input",
 GeneratedCell->True,
 CellAutoOverwrite->True,
 CellChangeTimes->{3.5398782767148438`*^9}]
}, Closed]],

Cell[CellGroupData[{

Cell["Example17", "Subsubsection",
 CellChangeTimes->{{3.539199084718422*^9, 3.5391990865992813`*^9}, 
   3.540401583064325*^9}],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"boxes19", " ", "=", " ", 
  RowBox[{"MakeBoxes", "[", 
   RowBox[{
    RowBox[{"ClearAll", "[", "debug", "]"}], ";", "\n", 
    RowBox[{"SetAttributes", "[", 
     RowBox[{"debug", ",", "HoldAll"}], "]"}], ";", "\n", 
    RowBox[{
     RowBox[{"debug", "[", "code_", "]"}], ":=", 
     RowBox[{"Internal`InheritedBlock", "[", 
      RowBox[{
       RowBox[{"{", "Message", "}"}], ",", 
       RowBox[{
        RowBox[{"Module", "[", 
         RowBox[{
          RowBox[{"{", "inMessage", "}"}], ",", 
          RowBox[{
           RowBox[{"Unprotect", "[", "Message", "]"}], ";", 
           "\[IndentingNewLine]", 
           RowBox[{
            RowBox[{
             RowBox[{"Message", "[", "args___", "]"}], "/;", 
             RowBox[{"!", 
              RowBox[{"MatchQ", "[", 
               RowBox[{
                RowBox[{"First", "[", 
                 RowBox[{"Hold", "[", "args", "]"}], "]"}], ",", "_$Off"}], 
               "]"}]}]}], ":=", 
            RowBox[{
             RowBox[{"Block", "[", 
              RowBox[{
               RowBox[{"{", 
                RowBox[{"inMessage", "=", "True"}], "}"}], ",", 
               RowBox[{
                RowBox[{"Print", "[", 
                 RowBox[{
                  RowBox[{
                   RowBox[{"{", 
                    RowBox[{
                    RowBox[{"Shallow", "/@", 
                    RowBox[{"Replace", "[", 
                    RowBox[{"#", ",", 
                    RowBox[{
                    RowBox[{"HoldForm", "[", 
                    RowBox[{"f_", "[", "___", "]"}], "]"}], "\[RuleDelayed]", 
                    
                    RowBox[{"HoldForm", "[", "f", "]"}]}], ",", "1"}], 
                    "]"}]}], ",", 
                    RowBox[{"Style", "[", 
                    RowBox[{
                    RowBox[{"Map", "[", 
                    RowBox[{"Short", ",", 
                    RowBox[{"Last", "[", "#", "]"}], ",", 
                    RowBox[{"{", "2", "}"}]}], "]"}], ",", "Red"}], "]"}]}], 
                    "}"}], "&"}], "@", 
                  RowBox[{"Drop", "[", 
                   RowBox[{
                    RowBox[{"Drop", "[", 
                    RowBox[{
                    RowBox[{"Stack", "[", "_", "]"}], ",", 
                    RowBox[{"-", "7"}]}], "]"}], ",", "4"}], "]"}]}], "]"}], 
                ";", "\[IndentingNewLine]", 
                RowBox[{"Message", "[", "args", "]"}], ";", 
                "\[IndentingNewLine]", 
                RowBox[{"Throw", "[", 
                 RowBox[{"$Failed", ",", "Message"}], "]"}], ";"}]}], "]"}], "/;", 
             RowBox[{"!", 
              RowBox[{"TrueQ", "[", "inMessage", "]"}]}]}]}], ";", 
           "\[IndentingNewLine]", 
           RowBox[{"Protect", "[", "Message", "]"}], ";"}]}], "]"}], ";", 
        "\[IndentingNewLine]", 
        RowBox[{"Catch", "[", 
         RowBox[{
          RowBox[{"StackComplete", "[", "code", "]"}], ",", "Message"}], 
         "]"}]}]}], "]"}]}]}], "]"}]}]], "Input",
 CellChangeTimes->{{3.5387583731484375`*^9, 3.5387583806523438`*^9}}],

Cell[BoxData[
 RowBox[{"RowBox", "[", 
  RowBox[{"{", 
   RowBox[{
    RowBox[{"RowBox", "[", 
     RowBox[{"{", 
      RowBox[{"\<\"ClearAll\"\>", ",", "\<\"[\"\>", ",", "\<\"debug\"\>", 
       ",", "\<\"]\"\>"}], "}"}], "]"}], ",", "\<\";\"\>", ",", 
    RowBox[{"RowBox", "[", 
     RowBox[{"{", 
      RowBox[{"\<\"SetAttributes\"\>", ",", "\<\"[\"\>", ",", 
       RowBox[{"RowBox", "[", 
        RowBox[{"{", 
         RowBox[{"\<\"debug\"\>", ",", "\<\",\"\>", ",", "\<\"HoldAll\"\>"}], 
         "}"}], "]"}], ",", "\<\"]\"\>"}], "}"}], "]"}], ",", "\<\";\"\>", 
    ",", 
    RowBox[{"RowBox", "[", 
     RowBox[{"{", 
      RowBox[{
       RowBox[{"RowBox", "[", 
        RowBox[{"{", 
         RowBox[{"\<\"debug\"\>", ",", "\<\"[\"\>", ",", "\<\"code_\"\>", 
          ",", "\<\"]\"\>"}], "}"}], "]"}], ",", "\<\":=\"\>", ",", 
       RowBox[{"RowBox", "[", 
        RowBox[{"{", 
         RowBox[{"\<\"Internal`InheritedBlock\"\>", ",", "\<\"[\"\>", ",", 
          RowBox[{"RowBox", "[", 
           RowBox[{"{", 
            RowBox[{
             RowBox[{"RowBox", "[", 
              RowBox[{"{", 
               
               RowBox[{"\<\"{\"\>", ",", "\<\"Message\"\>", 
                ",", "\<\"}\"\>"}], "}"}], "]"}], ",", "\<\",\"\>", ",", 
             RowBox[{"RowBox", "[", 
              RowBox[{"{", 
               RowBox[{
                RowBox[{"RowBox", "[", 
                 RowBox[{"{", 
                  RowBox[{"\<\"Module\"\>", ",", "\<\"[\"\>", ",", 
                   RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"{\"\>", ",", "\<\"inMessage\"\>", 
                    ",", "\<\"}\"\>"}], "}"}], "]"}], ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"Unprotect\"\>", ",", "\<\"[\"\>", 
                    ",", "\<\"Message\"\>", ",", "\<\"]\"\>"}], "}"}], "]"}], 
                    ",", "\<\";\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"Message\"\>", ",", "\<\"[\"\>", 
                    ",", "\<\"args___\"\>", ",", "\<\"]\"\>"}], "}"}], "]"}], 
                    ",", "\<\"/;\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"!\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"MatchQ\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"First\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"Hold\"\>", ",", "\<\"[\"\>", 
                    ",", "\<\"args\"\>", ",", "\<\"]\"\>"}], "}"}], "]"}], 
                    ",", "\<\"]\"\>"}], "}"}], "]"}], ",", "\<\",\"\>", 
                    ",", "\<\"_$Off\"\>"}], "}"}], "]"}], ",", "\<\"]\"\>"}], 
                    "}"}], "]"}]}], "}"}], "]"}]}], "}"}], "]"}], 
                    ",", "\<\":=\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"Block\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"{\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"inMessage\"\>", ",", "\<\"=\"\>", 
                    ",", "\<\"True\"\>"}], "}"}], "]"}], ",", "\<\"}\"\>"}], 
                    "}"}], "]"}], ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"Print\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"(\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"{\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"Shallow\"\>", ",", "\<\"/@\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"Replace\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"#1\"\>", ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"TagBox", "[", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"f_\"\>", ",", "\<\"[\"\>", 
                    ",", "\<\"___\"\>", ",", "\<\"]\"\>"}], "}"}], "]"}], ",",
                     "HoldForm"}], "]"}], ",", "\<\"\[RuleDelayed]\"\>", ",", 
                    
                    RowBox[{"TagBox", "[", 
                    RowBox[{"\<\"f\"\>", ",", "HoldForm"}], "]"}]}], "}"}], 
                    "]"}], ",", "\<\",\"\>", ",", "\<\"1\"\>"}], "}"}], "]"}],
                     ",", "\<\"]\"\>"}], "}"}], "]"}]}], "}"}], "]"}], 
                    ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"Style\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"Map\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"Short\"\>", ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"Last\"\>", ",", "\<\"[\"\>", 
                    ",", "\<\"#1\"\>", ",", "\<\"]\"\>"}], "}"}], "]"}], 
                    ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"{\"\>", ",", "\<\"2\"\>", ",", "\<\"}\"\>"}],
                     "}"}], "]"}]}], "}"}], "]"}], ",", "\<\"]\"\>"}], "}"}], 
                    "]"}], ",", "\<\",\"\>", ",", "\<\"Red\"\>"}], "}"}], 
                    "]"}], ",", "\<\"]\"\>"}], "}"}], "]"}]}], "}"}], "]"}], 
                    ",", "\<\"}\"\>"}], "}"}], "]"}], ",", "\<\"&\"\>"}], 
                    "}"}], "]"}], ",", "\<\")\"\>"}], "}"}], "]"}], 
                    ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"Drop\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"Drop\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"Stack\"\>", ",", "\<\"[\"\>", 
                    ",", "\<\"_\"\>", ",", "\<\"]\"\>"}], "}"}], "]"}], 
                    ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"-\"\>", ",", "\<\"7\"\>"}], "}"}], "]"}]}], 
                    "}"}], "]"}], ",", "\<\"]\"\>"}], "}"}], "]"}], 
                    ",", "\<\",\"\>", ",", "\<\"4\"\>"}], "}"}], "]"}], 
                    ",", "\<\"]\"\>"}], "}"}], "]"}], ",", "\<\"]\"\>"}], 
                    "}"}], "]"}], ",", "\<\"]\"\>"}], "}"}], "]"}], 
                    ",", "\<\";\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"Message\"\>", ",", "\<\"[\"\>", 
                    ",", "\<\"args\"\>", ",", "\<\"]\"\>"}], "}"}], "]"}], 
                    ",", "\<\";\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"Throw\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"$Failed\"\>", ",", "\<\",\"\>", 
                    ",", "\<\"Message\"\>"}], "}"}], "]"}], 
                    ",", "\<\"]\"\>"}], "}"}], "]"}], ",", "\<\";\"\>"}], 
                    "}"}], "]"}]}], "}"}], "]"}], ",", "\<\"]\"\>"}], "}"}], 
                    "]"}], ",", "\<\"/;\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"!\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"TrueQ\"\>", ",", "\<\"[\"\>", 
                    ",", "\<\"inMessage\"\>", ",", "\<\"]\"\>"}], "}"}], 
                    "]"}]}], "}"}], "]"}]}], "}"}], "]"}]}], "}"}], "]"}], 
                    ",", "\<\";\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"Protect\"\>", ",", "\<\"[\"\>", 
                    ",", "\<\"Message\"\>", ",", "\<\"]\"\>"}], "}"}], "]"}], 
                    ",", "\<\";\"\>"}], "}"}], "]"}]}], "}"}], "]"}], 
                   ",", "\<\"]\"\>"}], "}"}], "]"}], ",", "\<\";\"\>", ",", 
                RowBox[{"RowBox", "[", 
                 RowBox[{"{", 
                  RowBox[{"\<\"Catch\"\>", ",", "\<\"[\"\>", ",", 
                   RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"StackComplete\"\>", ",", "\<\"[\"\>", 
                    ",", "\<\"code\"\>", ",", "\<\"]\"\>"}], "}"}], "]"}], 
                    ",", "\<\",\"\>", ",", "\<\"Message\"\>"}], "}"}], "]"}], 
                   ",", "\<\"]\"\>"}], "}"}], "]"}]}], "}"}], "]"}]}], "}"}], 
           "]"}], ",", "\<\"]\"\>"}], "}"}], "]"}]}], "}"}], "]"}]}], "}"}], 
  "]"}]], "Output",
 CellChangeTimes->{3.538758381319336*^9, 3.538766634354492*^9, 
  3.5391990971637344`*^9, 3.539878302194336*^9}]
}, Open  ]],

Cell[BoxData[
 RowBox[{"prn", "@", 
  RowBox[{"FullCodeFormat", "@", "boxes19"}]}]], "Input",
 CellChangeTimes->{{3.5387583929472656`*^9, 3.5387583930097656`*^9}, {
   3.5398783066914062`*^9, 3.539878312078125*^9}, 3.540387642745253*^9}],

Cell[BoxData[
 RowBox[{"\n", 
  RowBox[{
   RowBox[{
    RowBox[{"ClearAll", "[", "debug", "]"}], ";"}], "\n", 
   RowBox[{
    RowBox[{"SetAttributes", "[", 
     RowBox[{"debug", ",", "HoldAll"}], "]"}], ";"}], "\n", 
   RowBox[{
    RowBox[{"debug", "[", "code_", "]"}], ":=", "\n", "\t", 
    RowBox[{"Internal`InheritedBlock", "[", "\t", "\t", "\n", "\t", "\t", 
     RowBox[{
      RowBox[{"{", "Message", "}"}], ",", "\t", "\t", "\t", "\t", "\n", "\t", 
      "\t", 
      RowBox[{
       RowBox[{"Module", "[", 
        RowBox[{
         RowBox[{"{", "inMessage", "}"}], ",", "\t", "\t", "\t", "\n", "\t", 
         "\t", "\t", 
         RowBox[{
          RowBox[{"Unprotect", "[", "Message", "]"}], ";", "\n", "\t", "\t", 
          "\t", 
          RowBox[{
           RowBox[{
            RowBox[{"Message", "[", "args___", "]"}], "/;", 
            RowBox[{"!", 
             RowBox[{"MatchQ", "[", 
              RowBox[{
               RowBox[{"First", "[", 
                RowBox[{"Hold", "[", "args", "]"}], "]"}], ",", "_$Off"}], 
              "]"}]}]}], ":=", "\t", "\t", "\t", "\t", "\n", "\t", "\t", "\t",
            "\t", 
           RowBox[{
            RowBox[{"Block", "[", 
             RowBox[{
              RowBox[{"{", 
               RowBox[{"inMessage", "=", "True"}], "}"}], ",", "\t", "\t", 
              "\t", "\t", "\t", "\n", "\t", "\t", "\t", "\t", "\t", 
              RowBox[{
               RowBox[{
               "Print", "[", "\t", "\t", "\t", "\t", "\t", "\t", "\n", "\t", 
                "\t", "\t", "\t", "\t", "\t", 
                RowBox[{
                 RowBox[{
                 "(", "\t", "\t", "\t", "\t", "\t", "\t", "\t", "\n", "\t", 
                  "\t", "\t", "\t", "\t", "\t", "\t", 
                  RowBox[{
                   RowBox[{
                   "{", "\t", "\t", "\t", "\t", "\t", "\t", "\t", "\t", "\n", 
                    "\t", "\t", "\t", "\t", "\t", "\t", "\t", "\t", 
                    RowBox[{
                    RowBox[{"Shallow", "/@", 
                    RowBox[{"Replace", "[", 
                    RowBox[{"#1", ",", 
                    RowBox[{
                    TagBox[
                    RowBox[{"f_", "[", "___", "]"}],
                    HoldForm], "\[RuleDelayed]", 
                    TagBox["f",
                    HoldForm]}], ",", "1"}], "]"}]}], ",", "\n", "\t", "\t", 
                    "\t", "\t", "\t", "\t", "\t", "\t", 
                    RowBox[{"Style", "[", 
                    RowBox[{
                    RowBox[{"Map", "[", 
                    RowBox[{"Short", ",", 
                    RowBox[{"Last", "[", "#1", "]"}], ",", 
                    RowBox[{"{", "2", "}"}]}], "]"}], ",", "Red"}], "]"}]}], 
                    "\n", "\t", "\t", "\t", "\t", "\t", "\t", "\t", "}"}], 
                   "&"}], "\n", "\t", "\t", "\t", "\t", "\t", "\t", ")"}], 
                 "[", "\n", "\t", "\t", "\t", "\t", "\t", "\t", "\t", 
                 RowBox[{"Drop", "[", 
                  RowBox[{
                   RowBox[{"Drop", "[", 
                    RowBox[{
                    RowBox[{"Stack", "[", "_", "]"}], ",", 
                    RowBox[{"-", "7"}]}], "]"}], ",", "4"}], "]"}], "\n", 
                 "\t", "\t", "\t", "\t", "\t", "\t", "]"}], "\n", "\t", "\t", 
                "\t", "\t", "\t", "]"}], ";", "\n", "\t", "\t", "\t", "\t", 
               "\t", 
               RowBox[{"Message", "[", "args", "]"}], ";", "\n", "\t", "\t", 
               "\t", "\t", "\t", 
               RowBox[{"Throw", "[", 
                RowBox[{"$Failed", ",", "Message"}], "]"}], ";"}]}], "\n", 
             "\t", "\t", "\t", "\t", "]"}], "\n", "\t", "\t", "\t", "\t", "/;",
             "\n", "\t", "\t", "\t", "\t", 
            RowBox[{"!", 
             RowBox[{"TrueQ", "[", "inMessage", "]"}]}]}]}], ";", "\n", "\t", 
          "\t", "\t", 
          RowBox[{"Protect", "[", "Message", "]"}], ";"}]}], "\n", "\t", "\t",
         "]"}], ";", "\n", "\t", "\t", 
       RowBox[{"Catch", "[", 
        RowBox[{
         RowBox[{"StackComplete", "[", "code", "]"}], ",", "Message"}], 
        "]"}]}]}], "\n", "\t", "]"}]}]}]}]], "Input",
 GeneratedCell->True,
 CellAutoOverwrite->True,
 CellChangeTimes->{3.539878309098633*^9}],

Cell[BoxData[
 RowBox[{"prn", "@", 
  RowBox[{"FullCodeFormatCompact", "@", "boxes19"}]}]], "Input",
 CellChangeTimes->{{3.539878327794922*^9, 3.5398783292851562`*^9}, 
   3.540387642787626*^9}],

Cell[BoxData[
 RowBox[{"\n", 
  RowBox[{
   RowBox[{
    RowBox[{"ClearAll", "[", "debug", "]"}], ";"}], "\n", 
   RowBox[{
    RowBox[{"SetAttributes", "[", 
     RowBox[{"debug", ",", "HoldAll"}], "]"}], ";"}], "\n", 
   RowBox[{
    RowBox[{"debug", "[", "code_", "]"}], ":=", "\n", "\t", 
    RowBox[{"Internal`InheritedBlock", "[", "\t", "\t", "\n", "\t", "\t", 
     RowBox[{
      RowBox[{"{", "Message", "}"}], ",", "\t", "\t", "\t", "\t", "\n", "\t", 
      "\t", 
      RowBox[{
       RowBox[{"Module", "[", 
        RowBox[{
         RowBox[{"{", "inMessage", "}"}], ",", "\t", "\t", "\t", "\n", "\t", 
         "\t", "\t", 
         RowBox[{
          RowBox[{"Unprotect", "[", "Message", "]"}], ";", "\n", "\t", "\t", 
          "\t", 
          RowBox[{
           RowBox[{
            RowBox[{"Message", "[", "args___", "]"}], "/;", 
            RowBox[{"!", 
             RowBox[{"MatchQ", "[", 
              RowBox[{
               RowBox[{"First", "[", 
                RowBox[{"Hold", "[", "args", "]"}], "]"}], ",", "_$Off"}], 
              "]"}]}]}], ":=", "\t", "\t", "\t", "\t", "\n", "\t", "\t", "\t",
            "\t", 
           RowBox[{
            RowBox[{"Block", "[", 
             RowBox[{
              RowBox[{"{", 
               RowBox[{"inMessage", "=", "True"}], "}"}], ",", "\t", "\t", 
              "\t", "\t", "\t", "\n", "\t", "\t", "\t", "\t", "\t", 
              RowBox[{
               RowBox[{
               "Print", "[", "\t", "\t", "\t", "\t", "\t", "\t", "\n", "\t", 
                "\t", "\t", "\t", "\t", "\t", 
                RowBox[{
                 RowBox[{
                 "(", "\t", "\t", "\t", "\t", "\t", "\t", "\t", "\n", "\t", 
                  "\t", "\t", "\t", "\t", "\t", "\t", 
                  RowBox[{
                   RowBox[{
                   "{", "\t", "\t", "\t", "\t", "\t", "\t", "\t", "\t", "\n", 
                    "\t", "\t", "\t", "\t", "\t", "\t", "\t", "\t", 
                    RowBox[{
                    RowBox[{"Shallow", "/@", 
                    RowBox[{"Replace", "[", 
                    RowBox[{"#1", ",", 
                    RowBox[{
                    TagBox[
                    RowBox[{"f_", "[", "___", "]"}],
                    HoldForm], "\[RuleDelayed]", 
                    TagBox["f",
                    HoldForm]}], ",", "1"}], "]"}]}], ",", "\n", "\t", "\t", 
                    "\t", "\t", "\t", "\t", "\t", "\t", 
                    RowBox[{"Style", "[", 
                    RowBox[{
                    RowBox[{"Map", "[", 
                    RowBox[{"Short", ",", 
                    RowBox[{"Last", "[", "#1", "]"}], ",", 
                    RowBox[{"{", "2", "}"}]}], "]"}], ",", "Red"}], "]"}]}], 
                    "}"}], "&"}], ")"}], "[", "\n", "\t", "\t", "\t", "\t", 
                 "\t", "\t", "\t", 
                 RowBox[{"Drop", "[", 
                  RowBox[{
                   RowBox[{"Drop", "[", 
                    RowBox[{
                    RowBox[{"Stack", "[", "_", "]"}], ",", 
                    RowBox[{"-", "7"}]}], "]"}], ",", "4"}], "]"}], "]"}], 
                "]"}], ";", "\n", "\t", "\t", "\t", "\t", "\t", 
               RowBox[{"Message", "[", "args", "]"}], ";", "\n", "\t", "\t", 
               "\t", "\t", "\t", 
               RowBox[{"Throw", "[", 
                RowBox[{"$Failed", ",", "Message"}], "]"}], ";"}]}], "]"}], 
            "\n", "\t", "\t", "\t", "\t", "/;", "\n", "\t", "\t", "\t", "\t", 
            
            RowBox[{"!", 
             RowBox[{"TrueQ", "[", "inMessage", "]"}]}]}]}], ";", "\n", "\t", 
          "\t", "\t", 
          RowBox[{"Protect", "[", "Message", "]"}], ";"}]}], "]"}], ";", "\n",
        "\t", "\t", 
       RowBox[{"Catch", "[", 
        RowBox[{
         RowBox[{"StackComplete", "[", "code", "]"}], ",", "Message"}], 
        "]"}]}]}], "]"}]}]}]}]], "Input",
 GeneratedCell->True,
 CellAutoOverwrite->True,
 CellChangeTimes->{3.539878330067383*^9}]
}, Closed]],

Cell[CellGroupData[{

Cell["Example18", "Subsubsection",
 CellChangeTimes->{{3.5391991838199844`*^9, 3.539199185312172*^9}, 
   3.540401583726426*^9}],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"boxes20", " ", "=", " ", 
  RowBox[{"MakeBoxes", "[", "\[IndentingNewLine]", 
   RowBox[{
    RowBox[{"ClearAll", "[", "symbolicHead", "]"}], ";", "\n", 
    RowBox[{"SetAttributes", "[", 
     RowBox[{"symbolicHead", ",", "HoldAllComplete"}], "]"}], ";", "\n", 
    RowBox[{
     RowBox[{"symbolicHead", "[", 
      RowBox[{"f_Symbol", "[", "___", "]"}], "]"}], ":=", "f"}], ";", "\n", 
    RowBox[{
     RowBox[{"symbolicHead", "[", 
      RowBox[{"f_", "[", "___", "]"}], "]"}], ":=", 
     RowBox[{"symbolicHead", "[", "f", "]"}]}], ";", "\n", 
    RowBox[{
     RowBox[{"symbolicHead", "[", "f_", "]"}], ":=", 
     RowBox[{"Head", "[", 
      RowBox[{"Unevaluated", "[", "f", "]"}], "]"}]}], ";", "\n", 
    "\[IndentingNewLine]", 
    RowBox[{"ClearAll", "[", "valueQ", "]"}], ";", "\n", 
    RowBox[{"SetAttributes", "[", 
     RowBox[{"valueQ", ",", "HoldAllComplete"}], "]"}], ";", "\n", 
    RowBox[{
     RowBox[{
      RowBox[{"valueQ", "[", "a_Symbol", "]"}], "/;", 
      RowBox[{
       RowBox[{"OwnValues", "[", "a", "]"}], "=!=", 
       RowBox[{"{", "}"}]}]}], ":=", 
     RowBox[{"With", "[", 
      RowBox[{
       RowBox[{"{", 
        RowBox[{"result", "=", 
         RowBox[{
          RowBox[{
           RowBox[{"(", 
            RowBox[{"#", "=!=", 
             RowBox[{"(", 
              RowBox[{"#", "/.", 
               RowBox[{"OwnValues", "[", "a", "]"}]}], ")"}]}], ")"}], "&"}], 
          "[", 
          RowBox[{"HoldComplete", "[", "a", "]"}], "]"}]}], "}"}], ",", 
       RowBox[{"result", "/;", "result"}]}], "]"}]}], ";", "\n", 
    "\[IndentingNewLine]", 
    RowBox[{
     RowBox[{
      RowBox[{"valueQ", "[", 
       RowBox[{"a", ":", 
        RowBox[{"f_Symbol", "[", "___", "]"}]}], "]"}], "/;", 
      RowBox[{
       RowBox[{"DownValues", "[", "f", "]"}], "=!=", 
       RowBox[{"{", "}"}]}]}], ":=", 
     RowBox[{"With", "[", 
      RowBox[{
       RowBox[{"{", 
        RowBox[{"result", "=", 
         RowBox[{
          RowBox[{
           RowBox[{"(", 
            RowBox[{"#", "=!=", 
             RowBox[{"(", 
              RowBox[{"#", "/.", 
               RowBox[{"DownValues", "[", "f", "]"}]}], ")"}]}], ")"}], "&"}],
           "@", 
          RowBox[{"HoldComplete", "[", "a", "]"}]}]}], "}"}], ",", 
       RowBox[{"result", "/;", "result"}]}], "]"}]}], ";", "\n", 
    "\[IndentingNewLine]", 
    RowBox[{
     RowBox[{"valueQ", "[", "a_", "]"}], ":=", 
     RowBox[{"With", "[", 
      RowBox[{
       RowBox[{"{", 
        RowBox[{"sub", "=", 
         RowBox[{"SubValues", "[", 
          RowBox[{"Evaluate", "[", 
           RowBox[{"symbolicHead", "[", "a", "]"}], "]"}], "]"}]}], "}"}], 
       ",", 
       RowBox[{
        RowBox[{"With", "[", 
         RowBox[{
          RowBox[{"{", 
           RowBox[{"result", "=", 
            RowBox[{
             RowBox[{
              RowBox[{"(", 
               RowBox[{"#", "=!=", 
                RowBox[{"(", 
                 RowBox[{"#", "/.", "sub"}], ")"}]}], ")"}], "&"}], "[", 
             RowBox[{"HoldComplete", "[", "a", "]"}], "]"}]}], "}"}], ",", 
          RowBox[{"result", "/;", "result"}]}], "]"}], "/;", 
        RowBox[{"sub", "=!=", 
         RowBox[{"{", "}"}]}]}]}], "]"}]}], ";", "\n", "\[IndentingNewLine]", 
    
    RowBox[{
     RowBox[{"valueQ", "[", "a_", "]"}], ":=", 
     RowBox[{"With", "[", 
      RowBox[{
       RowBox[{"{", 
        RowBox[{"upsyms", "=", 
         RowBox[{"Flatten", "@", 
          RowBox[{"Cases", "[", 
           RowBox[{
            RowBox[{"Unevaluated", "[", "a", "]"}], ",", 
            RowBox[{"s_Symbol", "\[RuleDelayed]", 
             RowBox[{"UpValues", "[", "s", "]"}]}], ",", "1", ",", 
            RowBox[{"Heads", "\[Rule]", "True"}]}], "]"}]}]}], "}"}], ",", 
       RowBox[{
        RowBox[{"With", "[", 
         RowBox[{
          RowBox[{"{", 
           RowBox[{"result", "=", 
            RowBox[{
             RowBox[{
              RowBox[{"(", 
               RowBox[{"#", "=!=", 
                RowBox[{"(", 
                 RowBox[{"#", "/.", "upsyms"}], ")"}]}], ")"}], "&"}], "[", 
             RowBox[{"HoldComplete", "[", "a", "]"}], "]"}]}], "}"}], ",", 
          RowBox[{"result", "/;", "result"}]}], "]"}], "/;", 
        RowBox[{"upsyms", "=!=", 
         RowBox[{"{", "}"}]}]}]}], "]"}]}], ";", "\n", "\[IndentingNewLine]", 
    
    RowBox[{
     RowBox[{"valueQ", "[", "_", "]"}], ":=", "False"}], ";"}], 
   "\[IndentingNewLine]", "]"}]}]], "Input",
 CellChangeTimes->{{3.5387668242373047`*^9, 3.5387668335126953`*^9}, {
  3.539199198912758*^9, 3.539199200905922*^9}}],

Cell[BoxData[
 RowBox[{"RowBox", "[", 
  RowBox[{"{", 
   RowBox[{
    RowBox[{"RowBox", "[", 
     RowBox[{"{", 
      RowBox[{"\<\"ClearAll\"\>", ",", "\<\"[\"\>", 
       ",", "\<\"symbolicHead\"\>", ",", "\<\"]\"\>"}], "}"}], "]"}], 
    ",", "\<\";\"\>", ",", 
    RowBox[{"RowBox", "[", 
     RowBox[{"{", 
      RowBox[{"\<\"SetAttributes\"\>", ",", "\<\"[\"\>", ",", 
       RowBox[{"RowBox", "[", 
        RowBox[{"{", 
         RowBox[{"\<\"symbolicHead\"\>", ",", "\<\",\"\>", 
          ",", "\<\"HoldAllComplete\"\>"}], "}"}], "]"}], ",", "\<\"]\"\>"}], 
      "}"}], "]"}], ",", "\<\";\"\>", ",", 
    RowBox[{"RowBox", "[", 
     RowBox[{"{", 
      RowBox[{
       RowBox[{"RowBox", "[", 
        RowBox[{"{", 
         RowBox[{"\<\"symbolicHead\"\>", ",", "\<\"[\"\>", ",", 
          RowBox[{"RowBox", "[", 
           RowBox[{"{", 
            
            RowBox[{"\<\"f_Symbol\"\>", ",", "\<\"[\"\>", ",", "\<\"___\"\>", 
             ",", "\<\"]\"\>"}], "}"}], "]"}], ",", "\<\"]\"\>"}], "}"}], 
        "]"}], ",", "\<\":=\"\>", ",", "\<\"f\"\>"}], "}"}], "]"}], 
    ",", "\<\";\"\>", ",", 
    RowBox[{"RowBox", "[", 
     RowBox[{"{", 
      RowBox[{
       RowBox[{"RowBox", "[", 
        RowBox[{"{", 
         RowBox[{"\<\"symbolicHead\"\>", ",", "\<\"[\"\>", ",", 
          RowBox[{"RowBox", "[", 
           RowBox[{"{", 
            
            RowBox[{"\<\"f_\"\>", ",", "\<\"[\"\>", ",", "\<\"___\"\>", 
             ",", "\<\"]\"\>"}], "}"}], "]"}], ",", "\<\"]\"\>"}], "}"}], 
        "]"}], ",", "\<\":=\"\>", ",", 
       RowBox[{"RowBox", "[", 
        RowBox[{"{", 
         RowBox[{"\<\"symbolicHead\"\>", ",", "\<\"[\"\>", ",", "\<\"f\"\>", 
          ",", "\<\"]\"\>"}], "}"}], "]"}]}], "}"}], "]"}], ",", "\<\";\"\>", 
    ",", 
    RowBox[{"RowBox", "[", 
     RowBox[{"{", 
      RowBox[{
       RowBox[{"RowBox", "[", 
        RowBox[{"{", 
         RowBox[{"\<\"symbolicHead\"\>", ",", "\<\"[\"\>", ",", "\<\"f_\"\>", 
          ",", "\<\"]\"\>"}], "}"}], "]"}], ",", "\<\":=\"\>", ",", 
       RowBox[{"RowBox", "[", 
        RowBox[{"{", 
         RowBox[{"\<\"Head\"\>", ",", "\<\"[\"\>", ",", 
          RowBox[{"RowBox", "[", 
           RowBox[{"{", 
            
            RowBox[{"\<\"Unevaluated\"\>", ",", "\<\"[\"\>", ",", "\<\"f\"\>",
              ",", "\<\"]\"\>"}], "}"}], "]"}], ",", "\<\"]\"\>"}], "}"}], 
        "]"}]}], "}"}], "]"}], ",", "\<\";\"\>", ",", 
    RowBox[{"RowBox", "[", 
     RowBox[{"{", 
      RowBox[{"\<\"ClearAll\"\>", ",", "\<\"[\"\>", ",", "\<\"valueQ\"\>", 
       ",", "\<\"]\"\>"}], "}"}], "]"}], ",", "\<\";\"\>", ",", 
    RowBox[{"RowBox", "[", 
     RowBox[{"{", 
      RowBox[{"\<\"SetAttributes\"\>", ",", "\<\"[\"\>", ",", 
       RowBox[{"RowBox", "[", 
        RowBox[{"{", 
         RowBox[{"\<\"valueQ\"\>", ",", "\<\",\"\>", 
          ",", "\<\"HoldAllComplete\"\>"}], "}"}], "]"}], ",", "\<\"]\"\>"}], 
      "}"}], "]"}], ",", "\<\";\"\>", ",", 
    RowBox[{"RowBox", "[", 
     RowBox[{"{", 
      RowBox[{
       RowBox[{"RowBox", "[", 
        RowBox[{"{", 
         RowBox[{
          RowBox[{"RowBox", "[", 
           RowBox[{"{", 
            
            RowBox[{"\<\"valueQ\"\>", ",", "\<\"[\"\>", 
             ",", "\<\"a_Symbol\"\>", ",", "\<\"]\"\>"}], "}"}], "]"}], 
          ",", "\<\"/;\"\>", ",", 
          RowBox[{"RowBox", "[", 
           RowBox[{"{", 
            RowBox[{
             RowBox[{"RowBox", "[", 
              RowBox[{"{", 
               
               RowBox[{"\<\"OwnValues\"\>", ",", "\<\"[\"\>", 
                ",", "\<\"a\"\>", ",", "\<\"]\"\>"}], "}"}], "]"}], 
             ",", "\<\"=!=\"\>", ",", 
             RowBox[{"RowBox", "[", 
              RowBox[{"{", 
               RowBox[{"\<\"{\"\>", ",", "\<\"}\"\>"}], "}"}], "]"}]}], "}"}],
            "]"}]}], "}"}], "]"}], ",", "\<\":=\"\>", ",", 
       RowBox[{"RowBox", "[", 
        RowBox[{"{", 
         RowBox[{"\<\"With\"\>", ",", "\<\"[\"\>", ",", 
          RowBox[{"RowBox", "[", 
           RowBox[{"{", 
            RowBox[{
             RowBox[{"RowBox", "[", 
              RowBox[{"{", 
               RowBox[{"\<\"{\"\>", ",", 
                RowBox[{"RowBox", "[", 
                 RowBox[{"{", 
                  RowBox[{"\<\"result\"\>", ",", "\<\"=\"\>", ",", 
                   RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"(\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"#1\"\>", ",", "\<\"=!=\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"(\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"#1\"\>", ",", "\<\"/.\"\>", 
                    ",", "\<\"\[InvisibleSpace]\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"OwnValues\"\>", ",", "\<\"[\"\>", 
                    ",", "\<\"a\"\>", ",", "\<\"]\"\>"}], "}"}], "]"}]}], 
                    "}"}], "]"}], ",", "\<\")\"\>"}], "}"}], "]"}]}], "}"}], 
                    "]"}], ",", "\<\"&\"\>"}], "}"}], "]"}], 
                    ",", "\<\")\"\>"}], "}"}], "]"}], ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"HoldComplete\"\>", ",", "\<\"[\"\>", 
                    ",", "\<\"a\"\>", ",", "\<\"]\"\>"}], "}"}], "]"}], 
                    ",", "\<\"]\"\>"}], "}"}], "]"}]}], "}"}], "]"}], 
                ",", "\<\"}\"\>"}], "}"}], "]"}], ",", "\<\",\"\>", ",", 
             RowBox[{"RowBox", "[", 
              RowBox[{"{", 
               
               RowBox[{"\<\"result\"\>", ",", "\<\"/;\"\>", 
                ",", "\<\"result\"\>"}], "}"}], "]"}]}], "}"}], "]"}], 
          ",", "\<\"]\"\>"}], "}"}], "]"}]}], "}"}], "]"}], ",", "\<\";\"\>", 
    ",", 
    RowBox[{"RowBox", "[", 
     RowBox[{"{", 
      RowBox[{
       RowBox[{"RowBox", "[", 
        RowBox[{"{", 
         RowBox[{
          RowBox[{"RowBox", "[", 
           RowBox[{"{", 
            RowBox[{"\<\"valueQ\"\>", ",", "\<\"[\"\>", ",", 
             RowBox[{"RowBox", "[", 
              RowBox[{"{", 
               RowBox[{"\<\"a\"\>", ",", "\<\":\"\>", ",", 
                RowBox[{"RowBox", "[", 
                 RowBox[{"{", 
                  
                  RowBox[{"\<\"f_Symbol\"\>", ",", "\<\"[\"\>", 
                   ",", "\<\"___\"\>", ",", "\<\"]\"\>"}], "}"}], "]"}]}], 
               "}"}], "]"}], ",", "\<\"]\"\>"}], "}"}], "]"}], 
          ",", "\<\"/;\"\>", ",", 
          RowBox[{"RowBox", "[", 
           RowBox[{"{", 
            RowBox[{
             RowBox[{"RowBox", "[", 
              RowBox[{"{", 
               
               RowBox[{"\<\"DownValues\"\>", ",", "\<\"[\"\>", 
                ",", "\<\"f\"\>", ",", "\<\"]\"\>"}], "}"}], "]"}], 
             ",", "\<\"=!=\"\>", ",", 
             RowBox[{"RowBox", "[", 
              RowBox[{"{", 
               RowBox[{"\<\"{\"\>", ",", "\<\"}\"\>"}], "}"}], "]"}]}], "}"}],
            "]"}]}], "}"}], "]"}], ",", "\<\":=\"\>", ",", 
       RowBox[{"RowBox", "[", 
        RowBox[{"{", 
         RowBox[{"\<\"With\"\>", ",", "\<\"[\"\>", ",", 
          RowBox[{"RowBox", "[", 
           RowBox[{"{", 
            RowBox[{
             RowBox[{"RowBox", "[", 
              RowBox[{"{", 
               RowBox[{"\<\"{\"\>", ",", 
                RowBox[{"RowBox", "[", 
                 RowBox[{"{", 
                  RowBox[{"\<\"result\"\>", ",", "\<\"=\"\>", ",", 
                   RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"(\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"#1\"\>", ",", "\<\"=!=\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"(\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"#1\"\>", ",", "\<\"/.\"\>", 
                    ",", "\<\"\[InvisibleSpace]\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"DownValues\"\>", ",", "\<\"[\"\>", 
                    ",", "\<\"f\"\>", ",", "\<\"]\"\>"}], "}"}], "]"}]}], 
                    "}"}], "]"}], ",", "\<\")\"\>"}], "}"}], "]"}]}], "}"}], 
                    "]"}], ",", "\<\"&\"\>"}], "}"}], "]"}], 
                    ",", "\<\")\"\>"}], "}"}], "]"}], ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"HoldComplete\"\>", ",", "\<\"[\"\>", 
                    ",", "\<\"a\"\>", ",", "\<\"]\"\>"}], "}"}], "]"}], 
                    ",", "\<\"]\"\>"}], "}"}], "]"}]}], "}"}], "]"}], 
                ",", "\<\"}\"\>"}], "}"}], "]"}], ",", "\<\",\"\>", ",", 
             RowBox[{"RowBox", "[", 
              RowBox[{"{", 
               
               RowBox[{"\<\"result\"\>", ",", "\<\"/;\"\>", 
                ",", "\<\"result\"\>"}], "}"}], "]"}]}], "}"}], "]"}], 
          ",", "\<\"]\"\>"}], "}"}], "]"}]}], "}"}], "]"}], ",", "\<\";\"\>", 
    ",", 
    RowBox[{"RowBox", "[", 
     RowBox[{"{", 
      RowBox[{
       RowBox[{"RowBox", "[", 
        RowBox[{"{", 
         RowBox[{"\<\"valueQ\"\>", ",", "\<\"[\"\>", ",", "\<\"a_\"\>", 
          ",", "\<\"]\"\>"}], "}"}], "]"}], ",", "\<\":=\"\>", ",", 
       RowBox[{"RowBox", "[", 
        RowBox[{"{", 
         RowBox[{"\<\"With\"\>", ",", "\<\"[\"\>", ",", 
          RowBox[{"RowBox", "[", 
           RowBox[{"{", 
            RowBox[{
             RowBox[{"RowBox", "[", 
              RowBox[{"{", 
               RowBox[{"\<\"{\"\>", ",", 
                RowBox[{"RowBox", "[", 
                 RowBox[{"{", 
                  RowBox[{"\<\"sub\"\>", ",", "\<\"=\"\>", ",", 
                   RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"SubValues\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"Evaluate\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"symbolicHead\"\>", ",", "\<\"[\"\>", 
                    ",", "\<\"a\"\>", ",", "\<\"]\"\>"}], "}"}], "]"}], 
                    ",", "\<\"]\"\>"}], "}"}], "]"}], ",", "\<\"]\"\>"}], 
                    "}"}], "]"}]}], "}"}], "]"}], ",", "\<\"}\"\>"}], "}"}], 
              "]"}], ",", "\<\",\"\>", ",", 
             RowBox[{"RowBox", "[", 
              RowBox[{"{", 
               RowBox[{
                RowBox[{"RowBox", "[", 
                 RowBox[{"{", 
                  RowBox[{"\<\"With\"\>", ",", "\<\"[\"\>", ",", 
                   RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"{\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"result\"\>", ",", "\<\"=\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"(\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"#1\"\>", ",", "\<\"=!=\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"(\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"#1\"\>", ",", "\<\"/.\"\>", 
                    ",", "\<\"\[InvisibleSpace]\"\>", ",", "\<\"sub\"\>"}], 
                    "}"}], "]"}], ",", "\<\")\"\>"}], "}"}], "]"}]}], "}"}], 
                    "]"}], ",", "\<\"&\"\>"}], "}"}], "]"}], 
                    ",", "\<\")\"\>"}], "}"}], "]"}], ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"HoldComplete\"\>", ",", "\<\"[\"\>", 
                    ",", "\<\"a\"\>", ",", "\<\"]\"\>"}], "}"}], "]"}], 
                    ",", "\<\"]\"\>"}], "}"}], "]"}]}], "}"}], "]"}], 
                    ",", "\<\"}\"\>"}], "}"}], "]"}], ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"result\"\>", ",", "\<\"/;\"\>", 
                    ",", "\<\"result\"\>"}], "}"}], "]"}]}], "}"}], "]"}], 
                   ",", "\<\"]\"\>"}], "}"}], "]"}], ",", "\<\"/;\"\>", ",", 
                RowBox[{"RowBox", "[", 
                 RowBox[{"{", 
                  RowBox[{"\<\"sub\"\>", ",", "\<\"=!=\"\>", ",", 
                   RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"{\"\>", ",", "\<\"}\"\>"}], "}"}], "]"}]}], 
                  "}"}], "]"}]}], "}"}], "]"}]}], "}"}], "]"}], 
          ",", "\<\"]\"\>"}], "}"}], "]"}]}], "}"}], "]"}], ",", "\<\";\"\>", 
    ",", 
    RowBox[{"RowBox", "[", 
     RowBox[{"{", 
      RowBox[{
       RowBox[{"RowBox", "[", 
        RowBox[{"{", 
         RowBox[{"\<\"valueQ\"\>", ",", "\<\"[\"\>", ",", "\<\"a_\"\>", 
          ",", "\<\"]\"\>"}], "}"}], "]"}], ",", "\<\":=\"\>", ",", 
       RowBox[{"RowBox", "[", 
        RowBox[{"{", 
         RowBox[{"\<\"With\"\>", ",", "\<\"[\"\>", ",", 
          RowBox[{"RowBox", "[", 
           RowBox[{"{", 
            RowBox[{
             RowBox[{"RowBox", "[", 
              RowBox[{"{", 
               RowBox[{"\<\"{\"\>", ",", 
                RowBox[{"RowBox", "[", 
                 RowBox[{"{", 
                  RowBox[{"\<\"upsyms\"\>", ",", "\<\"=\"\>", ",", 
                   RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"Flatten\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"Cases\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"Unevaluated\"\>", ",", "\<\"[\"\>", 
                    ",", "\<\"a\"\>", ",", "\<\"]\"\>"}], "}"}], "]"}], 
                    ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"s_Symbol\"\>", ",", "\<\"\[RuleDelayed]\"\>",
                     ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"UpValues\"\>", ",", "\<\"[\"\>", 
                    ",", "\<\"s\"\>", ",", "\<\"]\"\>"}], "}"}], "]"}]}], 
                    "}"}], "]"}], ",", "\<\",\"\>", ",", "\<\"1\"\>", 
                    ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"Heads\"\>", ",", "\<\"\[Rule]\"\>", 
                    ",", "\<\"True\"\>"}], "}"}], "]"}]}], "}"}], "]"}], 
                    ",", "\<\"]\"\>"}], "}"}], "]"}], ",", "\<\"]\"\>"}], 
                    "}"}], "]"}]}], "}"}], "]"}], ",", "\<\"}\"\>"}], "}"}], 
              "]"}], ",", "\<\",\"\>", ",", 
             RowBox[{"RowBox", "[", 
              RowBox[{"{", 
               RowBox[{
                RowBox[{"RowBox", "[", 
                 RowBox[{"{", 
                  RowBox[{"\<\"With\"\>", ",", "\<\"[\"\>", ",", 
                   RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"{\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"result\"\>", ",", "\<\"=\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"(\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"#1\"\>", ",", "\<\"=!=\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"(\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"#1\"\>", ",", "\<\"/.\"\>", 
                    ",", "\<\"\[InvisibleSpace]\"\>", ",", "\<\"upsyms\"\>"}],
                     "}"}], "]"}], ",", "\<\")\"\>"}], "}"}], "]"}]}], "}"}], 
                    "]"}], ",", "\<\"&\"\>"}], "}"}], "]"}], 
                    ",", "\<\")\"\>"}], "}"}], "]"}], ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"HoldComplete\"\>", ",", "\<\"[\"\>", 
                    ",", "\<\"a\"\>", ",", "\<\"]\"\>"}], "}"}], "]"}], 
                    ",", "\<\"]\"\>"}], "}"}], "]"}]}], "}"}], "]"}], 
                    ",", "\<\"}\"\>"}], "}"}], "]"}], ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"result\"\>", ",", "\<\"/;\"\>", 
                    ",", "\<\"result\"\>"}], "}"}], "]"}]}], "}"}], "]"}], 
                   ",", "\<\"]\"\>"}], "}"}], "]"}], ",", "\<\"/;\"\>", ",", 
                RowBox[{"RowBox", "[", 
                 RowBox[{"{", 
                  RowBox[{"\<\"upsyms\"\>", ",", "\<\"=!=\"\>", ",", 
                   RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"{\"\>", ",", "\<\"}\"\>"}], "}"}], "]"}]}], 
                  "}"}], "]"}]}], "}"}], "]"}]}], "}"}], "]"}], 
          ",", "\<\"]\"\>"}], "}"}], "]"}]}], "}"}], "]"}], ",", "\<\";\"\>", 
    ",", 
    RowBox[{"RowBox", "[", 
     RowBox[{"{", 
      RowBox[{
       RowBox[{"RowBox", "[", 
        RowBox[{"{", 
         RowBox[{"\<\"valueQ\"\>", ",", "\<\"[\"\>", ",", "\<\"_\"\>", 
          ",", "\<\"]\"\>"}], "}"}], "]"}], ",", "\<\":=\"\>", 
       ",", "\<\"False\"\>"}], "}"}], "]"}], ",", "\<\";\"\>"}], "}"}], 
  "]"}]], "Output",
 CellChangeTimes->{3.5387668345302734`*^9, 3.539199201575844*^9, 
  3.539878275078125*^9}]
}, Open  ]],

Cell[BoxData[
 RowBox[{"prn", "@", 
  RowBox[{"FullCodeFormat", "@", "boxes20"}]}]], "Input",
 CellChangeTimes->{{3.53876684921875*^9, 3.538766849713867*^9}, {
   3.5398782821728516`*^9, 3.539878287551758*^9}, 3.540387642830925*^9}],

Cell[BoxData[
 RowBox[{"\n", 
  RowBox[{
   RowBox[{
    RowBox[{"ClearAll", "[", "symbolicHead", "]"}], ";"}], "\n", 
   RowBox[{
    RowBox[{"SetAttributes", "[", 
     RowBox[{"symbolicHead", ",", "HoldAllComplete"}], "]"}], ";"}], "\n", 
   RowBox[{
    RowBox[{
     RowBox[{"symbolicHead", "[", 
      RowBox[{"f_Symbol", "[", "___", "]"}], "]"}], ":=", "\n", "\t", "f"}], 
    ";"}], "\n", 
   RowBox[{
    RowBox[{
     RowBox[{"symbolicHead", "[", 
      RowBox[{"f_", "[", "___", "]"}], "]"}], ":=", "\n", "\t", 
     RowBox[{"symbolicHead", "[", "f", "]"}]}], ";"}], "\n", 
   RowBox[{
    RowBox[{
     RowBox[{"symbolicHead", "[", "f_", "]"}], ":=", "\n", "\t", 
     RowBox[{"Head", "[", 
      RowBox[{"Unevaluated", "[", "f", "]"}], "]"}]}], ";"}], "\n", 
   RowBox[{
    RowBox[{"ClearAll", "[", "valueQ", "]"}], ";"}], "\n", 
   RowBox[{
    RowBox[{"SetAttributes", "[", 
     RowBox[{"valueQ", ",", "HoldAllComplete"}], "]"}], ";"}], "\n", 
   RowBox[{
    RowBox[{
     RowBox[{
      RowBox[{"valueQ", "[", "a_Symbol", "]"}], "/;", 
      RowBox[{
       RowBox[{"OwnValues", "[", "a", "]"}], "=!=", 
       RowBox[{"{", "}"}]}]}], ":=", "\n", "\t", 
     RowBox[{"With", "[", 
      RowBox[{
       RowBox[{"{", 
        RowBox[{"result", "=", 
         RowBox[{
          RowBox[{"(", 
           RowBox[{
            RowBox[{"#1", "=!=", 
             RowBox[{"(", 
              RowBox[{"#1", "/.", "\[InvisibleSpace]", 
               RowBox[{"OwnValues", "[", "a", "]"}]}], ")"}]}], "&"}], ")"}], 
          "[", 
          RowBox[{"HoldComplete", "[", "a", "]"}], "]"}]}], "}"}], ",", "\n", 
       "\t", "\t", 
       RowBox[{"result", "/;", "result"}]}], "\n", "\t", "]"}]}], ";"}], "\n", 
   RowBox[{
    RowBox[{
     RowBox[{
      RowBox[{"valueQ", "[", 
       RowBox[{"a", ":", 
        RowBox[{"f_Symbol", "[", "___", "]"}]}], "]"}], "/;", 
      RowBox[{
       RowBox[{"DownValues", "[", "f", "]"}], "=!=", 
       RowBox[{"{", "}"}]}]}], ":=", "\n", "\t", 
     RowBox[{"With", "[", 
      RowBox[{
       RowBox[{"{", 
        RowBox[{"result", "=", 
         RowBox[{
          RowBox[{"(", 
           RowBox[{
            RowBox[{"#1", "=!=", 
             RowBox[{"(", 
              RowBox[{"#1", "/.", "\[InvisibleSpace]", 
               RowBox[{"DownValues", "[", "f", "]"}]}], ")"}]}], "&"}], ")"}],
           "[", 
          RowBox[{"HoldComplete", "[", "a", "]"}], "]"}]}], "}"}], ",", "\n", 
       "\t", "\t", 
       RowBox[{"result", "/;", "result"}]}], "\n", "\t", "]"}]}], ";"}], "\n", 
   RowBox[{
    RowBox[{
     RowBox[{"valueQ", "[", "a_", "]"}], ":=", "\n", "\t", 
     RowBox[{"With", "[", 
      RowBox[{
       RowBox[{"{", 
        RowBox[{"sub", "=", 
         RowBox[{"SubValues", "[", 
          RowBox[{"Evaluate", "[", 
           RowBox[{"symbolicHead", "[", "a", "]"}], "]"}], "]"}]}], "}"}], 
       ",", "\t", "\t", "\n", "\t", "\t", 
       RowBox[{
        RowBox[{"With", "[", 
         RowBox[{
          RowBox[{"{", 
           RowBox[{"result", "=", 
            RowBox[{
             RowBox[{"(", 
              RowBox[{
               RowBox[{"#1", "=!=", 
                RowBox[{"(", 
                 RowBox[{"#1", "/.", "\[InvisibleSpace]", "sub"}], ")"}]}], 
               "&"}], ")"}], "[", 
             RowBox[{"HoldComplete", "[", "a", "]"}], "]"}]}], "}"}], ",", 
          "\n", "\t", "\t", "\t", 
          RowBox[{"result", "/;", "result"}]}], "\n", "\t", "\t", "]"}], "\n",
         "\t", "\t", "/;", "\n", "\t", "\t", 
        RowBox[{"sub", "=!=", 
         RowBox[{"{", "}"}]}]}]}], "\n", "\t", "]"}]}], ";"}], "\n", 
   RowBox[{
    RowBox[{
     RowBox[{"valueQ", "[", "a_", "]"}], ":=", "\n", "\t", 
     RowBox[{"With", "[", "\n", "\t", 
      RowBox[{
       RowBox[{"{", "\n", "\t", "\t", 
        RowBox[{"upsyms", "=", "\n", "\t", "\t", "\t", 
         RowBox[{"Flatten", "[", "\n", "\t", "\t", "\t", "\t", 
          RowBox[{"Cases", "[", "\n", "\t", "\t", "\t", "\t", "\t", 
           RowBox[{
            RowBox[{"Unevaluated", "[", "a", "]"}], ",", 
            RowBox[{"s_Symbol", "\[RuleDelayed]", 
             RowBox[{"UpValues", "[", "s", "]"}]}], ",", "1", ",", 
            RowBox[{"Heads", "\[Rule]", "True"}]}], "\n", "\t", "\t", "\t", 
           "\t", "]"}], "\n", "\t", "\t", "\t", "]"}]}], "\n", "\t", "}"}], 
       ",", "\t", "\t", "\n", "\t", "\t", 
       RowBox[{
        RowBox[{"With", "[", 
         RowBox[{
          RowBox[{"{", 
           RowBox[{"result", "=", 
            RowBox[{
             RowBox[{"(", 
              RowBox[{
               RowBox[{"#1", "=!=", 
                RowBox[{"(", 
                 RowBox[{"#1", "/.", "\[InvisibleSpace]", "upsyms"}], ")"}]}],
                "&"}], ")"}], "[", 
             RowBox[{"HoldComplete", "[", "a", "]"}], "]"}]}], "}"}], ",", 
          "\n", "\t", "\t", "\t", 
          RowBox[{"result", "/;", "result"}]}], "\n", "\t", "\t", "]"}], "\n",
         "\t", "\t", "/;", "\n", "\t", "\t", 
        RowBox[{"upsyms", "=!=", 
         RowBox[{"{", "}"}]}]}]}], "\n", "\t", "]"}]}], ";"}], "\n", 
   RowBox[{
    RowBox[{
     RowBox[{"valueQ", "[", "_", "]"}], ":=", "\n", "\t", "False"}], 
    ";"}]}]}]], "Input",
 GeneratedCell->True,
 CellAutoOverwrite->True,
 CellChangeTimes->{3.5398782846679688`*^9}],

Cell[BoxData[
 RowBox[{"prn", "@", 
  RowBox[{"FullCodeFormatCompact", "@", "boxes20"}]}]], "Input",
 CellChangeTimes->{{3.5398782994765625`*^9, 3.5398783011064453`*^9}, 
   3.540387642874824*^9}],

Cell[BoxData[
 RowBox[{"\n", 
  RowBox[{
   RowBox[{
    RowBox[{"ClearAll", "[", "symbolicHead", "]"}], ";"}], "\n", 
   RowBox[{
    RowBox[{"SetAttributes", "[", 
     RowBox[{"symbolicHead", ",", "HoldAllComplete"}], "]"}], ";"}], "\n", 
   RowBox[{
    RowBox[{
     RowBox[{"symbolicHead", "[", 
      RowBox[{"f_Symbol", "[", "___", "]"}], "]"}], ":=", "\n", "\t", "f"}], 
    ";"}], "\n", 
   RowBox[{
    RowBox[{
     RowBox[{"symbolicHead", "[", 
      RowBox[{"f_", "[", "___", "]"}], "]"}], ":=", "\n", "\t", 
     RowBox[{"symbolicHead", "[", "f", "]"}]}], ";"}], "\n", 
   RowBox[{
    RowBox[{
     RowBox[{"symbolicHead", "[", "f_", "]"}], ":=", "\n", "\t", 
     RowBox[{"Head", "[", 
      RowBox[{"Unevaluated", "[", "f", "]"}], "]"}]}], ";"}], "\n", 
   RowBox[{
    RowBox[{"ClearAll", "[", "valueQ", "]"}], ";"}], "\n", 
   RowBox[{
    RowBox[{"SetAttributes", "[", 
     RowBox[{"valueQ", ",", "HoldAllComplete"}], "]"}], ";"}], "\n", 
   RowBox[{
    RowBox[{
     RowBox[{
      RowBox[{"valueQ", "[", "a_Symbol", "]"}], "/;", 
      RowBox[{
       RowBox[{"OwnValues", "[", "a", "]"}], "=!=", 
       RowBox[{"{", "}"}]}]}], ":=", "\n", "\t", 
     RowBox[{"With", "[", 
      RowBox[{
       RowBox[{"{", 
        RowBox[{"result", "=", 
         RowBox[{
          RowBox[{"(", 
           RowBox[{
            RowBox[{"#1", "=!=", 
             RowBox[{"(", 
              RowBox[{"#1", "/.", "\[InvisibleSpace]", 
               RowBox[{"OwnValues", "[", "a", "]"}]}], ")"}]}], "&"}], ")"}], 
          "[", 
          RowBox[{"HoldComplete", "[", "a", "]"}], "]"}]}], "}"}], ",", "\n", 
       "\t", "\t", 
       RowBox[{"result", "/;", "result"}]}], "]"}]}], ";"}], "\n", 
   RowBox[{
    RowBox[{
     RowBox[{
      RowBox[{"valueQ", "[", 
       RowBox[{"a", ":", 
        RowBox[{"f_Symbol", "[", "___", "]"}]}], "]"}], "/;", 
      RowBox[{
       RowBox[{"DownValues", "[", "f", "]"}], "=!=", 
       RowBox[{"{", "}"}]}]}], ":=", "\n", "\t", 
     RowBox[{"With", "[", 
      RowBox[{
       RowBox[{"{", 
        RowBox[{"result", "=", 
         RowBox[{
          RowBox[{"(", 
           RowBox[{
            RowBox[{"#1", "=!=", 
             RowBox[{"(", 
              RowBox[{"#1", "/.", "\[InvisibleSpace]", 
               RowBox[{"DownValues", "[", "f", "]"}]}], ")"}]}], "&"}], ")"}],
           "[", 
          RowBox[{"HoldComplete", "[", "a", "]"}], "]"}]}], "}"}], ",", "\n", 
       "\t", "\t", 
       RowBox[{"result", "/;", "result"}]}], "]"}]}], ";"}], "\n", 
   RowBox[{
    RowBox[{
     RowBox[{"valueQ", "[", "a_", "]"}], ":=", "\n", "\t", 
     RowBox[{"With", "[", 
      RowBox[{
       RowBox[{"{", 
        RowBox[{"sub", "=", 
         RowBox[{"SubValues", "[", 
          RowBox[{"Evaluate", "[", 
           RowBox[{"symbolicHead", "[", "a", "]"}], "]"}], "]"}]}], "}"}], 
       ",", "\t", "\t", "\n", "\t", "\t", 
       RowBox[{
        RowBox[{"With", "[", 
         RowBox[{
          RowBox[{"{", 
           RowBox[{"result", "=", 
            RowBox[{
             RowBox[{"(", 
              RowBox[{
               RowBox[{"#1", "=!=", 
                RowBox[{"(", 
                 RowBox[{"#1", "/.", "\[InvisibleSpace]", "sub"}], ")"}]}], 
               "&"}], ")"}], "[", 
             RowBox[{"HoldComplete", "[", "a", "]"}], "]"}]}], "}"}], ",", 
          "\n", "\t", "\t", "\t", 
          RowBox[{"result", "/;", "result"}]}], "]"}], "\n", "\t", "\t", "/;",
         "\n", "\t", "\t", 
        RowBox[{"sub", "=!=", 
         RowBox[{"{", "}"}]}]}]}], "]"}]}], ";"}], "\n", 
   RowBox[{
    RowBox[{
     RowBox[{"valueQ", "[", "a_", "]"}], ":=", "\n", "\t", 
     RowBox[{"With", "[", "\n", "\t", 
      RowBox[{
       RowBox[{"{", "\n", "\t", "\t", 
        RowBox[{"upsyms", "=", "\n", "\t", "\t", "\t", 
         RowBox[{"Flatten", "[", "\n", "\t", "\t", "\t", "\t", 
          RowBox[{"Cases", "[", "\n", "\t", "\t", "\t", "\t", "\t", 
           RowBox[{
            RowBox[{"Unevaluated", "[", "a", "]"}], ",", 
            RowBox[{"s_Symbol", "\[RuleDelayed]", 
             RowBox[{"UpValues", "[", "s", "]"}]}], ",", "1", ",", 
            RowBox[{"Heads", "\[Rule]", "True"}]}], "]"}], "]"}]}], "}"}], 
       ",", "\t", "\t", "\n", "\t", "\t", 
       RowBox[{
        RowBox[{"With", "[", 
         RowBox[{
          RowBox[{"{", 
           RowBox[{"result", "=", 
            RowBox[{
             RowBox[{"(", 
              RowBox[{
               RowBox[{"#1", "=!=", 
                RowBox[{"(", 
                 RowBox[{"#1", "/.", "\[InvisibleSpace]", "upsyms"}], ")"}]}],
                "&"}], ")"}], "[", 
             RowBox[{"HoldComplete", "[", "a", "]"}], "]"}]}], "}"}], ",", 
          "\n", "\t", "\t", "\t", 
          RowBox[{"result", "/;", "result"}]}], "]"}], "\n", "\t", "\t", "/;",
         "\n", "\t", "\t", 
        RowBox[{"upsyms", "=!=", 
         RowBox[{"{", "}"}]}]}]}], "]"}]}], ";"}], "\n", 
   RowBox[{
    RowBox[{
     RowBox[{"valueQ", "[", "_", "]"}], ":=", "\n", "\t", "False"}], 
    ";"}]}]}]], "Input",
 GeneratedCell->True,
 CellAutoOverwrite->True,
 CellChangeTimes->{3.539878301883789*^9}]
}, Closed]],

Cell[CellGroupData[{

Cell["Example19", "Subsubsection",
 CellChangeTimes->{{3.5391996021295547`*^9, 3.5391996032125626`*^9}, 
   3.540401584386856*^9}],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"boxes21", " ", "=", " ", 
  RowBox[{"MakeBoxes", "[", "\[IndentingNewLine]", 
   RowBox[{
    RowBox[{"SetAttributes", "[", 
     RowBox[{"valueQ1", ",", "HoldAll"}], "]"}], ";", "\n", 
    "\[IndentingNewLine]", 
    RowBox[{
     RowBox[{"valueQ1", "[", "expr_", "]"}], ":=", 
     RowBox[{"Module", "[", 
      RowBox[{
       RowBox[{"{", 
        RowBox[{"P", ",", 
         RowBox[{"R", "=", "False"}]}], "}"}], ",", 
       RowBox[{
        RowBox[{"P", "=", 
         RowBox[{
          RowBox[{"(", 
           RowBox[{"P", "=", 
            RowBox[{
             RowBox[{"Return", "[", 
              RowBox[{
               RowBox[{"R", "=", "True"}], ",", "TraceScan"}], "]"}], "&"}]}],
            ")"}], "&"}]}], ";", "\[IndentingNewLine]", 
        RowBox[{"TraceScan", "[", 
         RowBox[{"P", ",", "expr", ",", 
          RowBox[{"TraceDepth", "\[Rule]", "1"}]}], "]"}], ";", 
        "\[IndentingNewLine]", "R"}]}], "]"}]}], ";", "\n", 
    "\[IndentingNewLine]", 
    RowBox[{"SetAttributes", "[", 
     RowBox[{"valueQ2", ",", "HoldAll"}], "]"}], ";", "\n", 
    "\[IndentingNewLine]", 
    RowBox[{
     RowBox[{"valueQ2", "[", "expr_", "]"}], ":=", 
     RowBox[{"Module", "[", 
      RowBox[{
       RowBox[{"{", 
        RowBox[{"P", ",", 
         RowBox[{"R", "=", "False"}]}], "}"}], ",", 
       RowBox[{
        RowBox[{"P", "=", 
         RowBox[{
          RowBox[{"(", 
           RowBox[{"P", "=", 
            RowBox[{
             RowBox[{"Return", "[", 
              RowBox[{
               RowBox[{"R", "=", "True"}], ",", "TraceScan"}], "]"}], "&"}]}],
            ")"}], "&"}]}], ";", "\[IndentingNewLine]", 
        RowBox[{"TraceScan", "[", 
         RowBox[{"P", ",", "expr"}], "]"}], ";", "\[IndentingNewLine]", 
        "R"}]}], "]"}]}], ";", "\n", "\[IndentingNewLine]", 
    RowBox[{"SetAttributes", "[", 
     RowBox[{"valueQ3", ",", "HoldAll"}], "]"}], ";", "\n", 
    "\[IndentingNewLine]", 
    RowBox[{
     RowBox[{"valueQ3", "[", "expr_", "]"}], ":=", 
     RowBox[{"Block", "[", 
      RowBox[{
       RowBox[{"{", "Print", "}"}], ",", 
       RowBox[{
        RowBox[{"TraceScan", "[", 
         RowBox[{
          RowBox[{"Null", "&"}], ",", "expr", ",", "_", ",", 
          RowBox[{
           RowBox[{"If", "[", 
            RowBox[{
             RowBox[{"#", "=!=", 
              RowBox[{"HoldForm", "[", "#2", "]"}]}], ",", 
             RowBox[{"Return", "[", 
              RowBox[{"True", ",", "TraceScan"}], "]"}]}], "]"}], "&"}]}], 
         "]"}], "//", "TrueQ"}]}], "]"}]}]}], "]"}]}]], "Input",
 CellChangeTimes->{{3.5387670931035156`*^9, 3.5387671366015625`*^9}, {
  3.538767176881836*^9, 3.538767178334961*^9}}],

Cell[BoxData[
 RowBox[{"RowBox", "[", 
  RowBox[{"{", 
   RowBox[{
    RowBox[{"RowBox", "[", 
     RowBox[{"{", 
      RowBox[{"\<\"SetAttributes\"\>", ",", "\<\"[\"\>", ",", 
       RowBox[{"RowBox", "[", 
        RowBox[{"{", 
         RowBox[{"\<\"valueQ1\"\>", ",", "\<\",\"\>", 
          ",", "\<\"HoldAll\"\>"}], "}"}], "]"}], ",", "\<\"]\"\>"}], "}"}], 
     "]"}], ",", "\<\";\"\>", ",", 
    RowBox[{"RowBox", "[", 
     RowBox[{"{", 
      RowBox[{
       RowBox[{"RowBox", "[", 
        RowBox[{"{", 
         RowBox[{"\<\"valueQ1\"\>", ",", "\<\"[\"\>", ",", "\<\"expr_\"\>", 
          ",", "\<\"]\"\>"}], "}"}], "]"}], ",", "\<\":=\"\>", ",", 
       RowBox[{"RowBox", "[", 
        RowBox[{"{", 
         RowBox[{"\<\"Module\"\>", ",", "\<\"[\"\>", ",", 
          RowBox[{"RowBox", "[", 
           RowBox[{"{", 
            RowBox[{
             RowBox[{"RowBox", "[", 
              RowBox[{"{", 
               RowBox[{"\<\"{\"\>", ",", 
                RowBox[{"RowBox", "[", 
                 RowBox[{"{", 
                  RowBox[{"\<\"P\"\>", ",", "\<\",\"\>", ",", 
                   RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"R\"\>", ",", "\<\"=\"\>", 
                    ",", "\<\"False\"\>"}], "}"}], "]"}]}], "}"}], "]"}], 
                ",", "\<\"}\"\>"}], "}"}], "]"}], ",", "\<\",\"\>", ",", 
             RowBox[{"RowBox", "[", 
              RowBox[{"{", 
               RowBox[{
                RowBox[{"RowBox", "[", 
                 RowBox[{"{", 
                  RowBox[{"\<\"P\"\>", ",", "\<\"=\"\>", ",", 
                   RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"(\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"P\"\>", ",", "\<\"=\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"Return\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"R\"\>", ",", "\<\"=\"\>", 
                    ",", "\<\"True\"\>"}], "}"}], "]"}], ",", "\<\",\"\>", 
                    ",", "\<\"TraceScan\"\>"}], "}"}], "]"}], 
                    ",", "\<\"]\"\>"}], "}"}], "]"}], ",", "\<\"&\"\>"}], 
                    "}"}], "]"}]}], "}"}], "]"}], ",", "\<\")\"\>"}], "}"}], 
                    "]"}], ",", "\<\"&\"\>"}], "}"}], "]"}]}], "}"}], "]"}], 
                ",", "\<\";\"\>", ",", 
                RowBox[{"RowBox", "[", 
                 RowBox[{"{", 
                  RowBox[{"\<\"TraceScan\"\>", ",", "\<\"[\"\>", ",", 
                   RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"P\"\>", ",", "\<\",\"\>", 
                    ",", "\<\"expr\"\>", ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"TraceDepth\"\>", ",", "\<\"\[Rule]\"\>", 
                    ",", "\<\"1\"\>"}], "}"}], "]"}]}], "}"}], "]"}], 
                   ",", "\<\"]\"\>"}], "}"}], "]"}], ",", "\<\";\"\>", 
                ",", "\<\"R\"\>"}], "}"}], "]"}]}], "}"}], "]"}], 
          ",", "\<\"]\"\>"}], "}"}], "]"}]}], "}"}], "]"}], ",", "\<\";\"\>", 
    ",", 
    RowBox[{"RowBox", "[", 
     RowBox[{"{", 
      RowBox[{"\<\"SetAttributes\"\>", ",", "\<\"[\"\>", ",", 
       RowBox[{"RowBox", "[", 
        RowBox[{"{", 
         RowBox[{"\<\"valueQ2\"\>", ",", "\<\",\"\>", 
          ",", "\<\"HoldAll\"\>"}], "}"}], "]"}], ",", "\<\"]\"\>"}], "}"}], 
     "]"}], ",", "\<\";\"\>", ",", 
    RowBox[{"RowBox", "[", 
     RowBox[{"{", 
      RowBox[{
       RowBox[{"RowBox", "[", 
        RowBox[{"{", 
         RowBox[{"\<\"valueQ2\"\>", ",", "\<\"[\"\>", ",", "\<\"expr_\"\>", 
          ",", "\<\"]\"\>"}], "}"}], "]"}], ",", "\<\":=\"\>", ",", 
       RowBox[{"RowBox", "[", 
        RowBox[{"{", 
         RowBox[{"\<\"Module\"\>", ",", "\<\"[\"\>", ",", 
          RowBox[{"RowBox", "[", 
           RowBox[{"{", 
            RowBox[{
             RowBox[{"RowBox", "[", 
              RowBox[{"{", 
               RowBox[{"\<\"{\"\>", ",", 
                RowBox[{"RowBox", "[", 
                 RowBox[{"{", 
                  RowBox[{"\<\"P\"\>", ",", "\<\",\"\>", ",", 
                   RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"R\"\>", ",", "\<\"=\"\>", 
                    ",", "\<\"False\"\>"}], "}"}], "]"}]}], "}"}], "]"}], 
                ",", "\<\"}\"\>"}], "}"}], "]"}], ",", "\<\",\"\>", ",", 
             RowBox[{"RowBox", "[", 
              RowBox[{"{", 
               RowBox[{
                RowBox[{"RowBox", "[", 
                 RowBox[{"{", 
                  RowBox[{"\<\"P\"\>", ",", "\<\"=\"\>", ",", 
                   RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"(\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"P\"\>", ",", "\<\"=\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"Return\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"R\"\>", ",", "\<\"=\"\>", 
                    ",", "\<\"True\"\>"}], "}"}], "]"}], ",", "\<\",\"\>", 
                    ",", "\<\"TraceScan\"\>"}], "}"}], "]"}], 
                    ",", "\<\"]\"\>"}], "}"}], "]"}], ",", "\<\"&\"\>"}], 
                    "}"}], "]"}]}], "}"}], "]"}], ",", "\<\")\"\>"}], "}"}], 
                    "]"}], ",", "\<\"&\"\>"}], "}"}], "]"}]}], "}"}], "]"}], 
                ",", "\<\";\"\>", ",", 
                RowBox[{"RowBox", "[", 
                 RowBox[{"{", 
                  RowBox[{"\<\"TraceScan\"\>", ",", "\<\"[\"\>", ",", 
                   RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"P\"\>", ",", "\<\",\"\>", 
                    ",", "\<\"expr\"\>"}], "}"}], "]"}], ",", "\<\"]\"\>"}], 
                  "}"}], "]"}], ",", "\<\";\"\>", ",", "\<\"R\"\>"}], "}"}], 
              "]"}]}], "}"}], "]"}], ",", "\<\"]\"\>"}], "}"}], "]"}]}], 
      "}"}], "]"}], ",", "\<\";\"\>", ",", 
    RowBox[{"RowBox", "[", 
     RowBox[{"{", 
      RowBox[{"\<\"SetAttributes\"\>", ",", "\<\"[\"\>", ",", 
       RowBox[{"RowBox", "[", 
        RowBox[{"{", 
         RowBox[{"\<\"valueQ3\"\>", ",", "\<\",\"\>", 
          ",", "\<\"HoldAll\"\>"}], "}"}], "]"}], ",", "\<\"]\"\>"}], "}"}], 
     "]"}], ",", "\<\";\"\>", ",", 
    RowBox[{"RowBox", "[", 
     RowBox[{"{", 
      RowBox[{
       RowBox[{"RowBox", "[", 
        RowBox[{"{", 
         RowBox[{"\<\"valueQ3\"\>", ",", "\<\"[\"\>", ",", "\<\"expr_\"\>", 
          ",", "\<\"]\"\>"}], "}"}], "]"}], ",", "\<\":=\"\>", ",", 
       RowBox[{"RowBox", "[", 
        RowBox[{"{", 
         RowBox[{"\<\"Block\"\>", ",", "\<\"[\"\>", ",", 
          RowBox[{"RowBox", "[", 
           RowBox[{"{", 
            RowBox[{
             RowBox[{"RowBox", "[", 
              RowBox[{"{", 
               RowBox[{"\<\"{\"\>", ",", "\<\"Print\"\>", ",", "\<\"}\"\>"}], 
               "}"}], "]"}], ",", "\<\",\"\>", ",", 
             RowBox[{"RowBox", "[", 
              RowBox[{"{", 
               RowBox[{"\<\"TrueQ\"\>", ",", "\<\"[\"\>", ",", 
                RowBox[{"RowBox", "[", 
                 RowBox[{"{", 
                  RowBox[{"\<\"TraceScan\"\>", ",", "\<\"[\"\>", ",", 
                   RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"Null\"\>", ",", "\<\"&\"\>"}], "}"}], "]"}], 
                    ",", "\<\",\"\>", ",", "\<\"expr\"\>", ",", "\<\",\"\>", 
                    ",", "\<\"_\"\>", ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"If\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"#1\"\>", ",", "\<\"=!=\"\>", ",", 
                    RowBox[{"TagBox", "[", 
                    RowBox[{"\<\"#2\"\>", ",", "HoldForm"}], "]"}]}], "}"}], 
                    "]"}], ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"Return\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"True\"\>", ",", "\<\",\"\>", 
                    ",", "\<\"TraceScan\"\>"}], "}"}], "]"}], 
                    ",", "\<\"]\"\>"}], "}"}], "]"}]}], "}"}], "]"}], 
                    ",", "\<\"]\"\>"}], "}"}], "]"}], ",", "\<\"&\"\>"}], 
                    "}"}], "]"}]}], "}"}], "]"}], ",", "\<\"]\"\>"}], "}"}], 
                 "]"}], ",", "\<\"]\"\>"}], "}"}], "]"}]}], "}"}], "]"}], 
          ",", "\<\"]\"\>"}], "}"}], "]"}]}], "}"}], "]"}]}], "}"}], 
  "]"}]], "Output",
 CellChangeTimes->{
  3.5387671077529297`*^9, 3.538767138573242*^9, 3.538767184126953*^9, 
   3.539199605030922*^9, {3.539878324044922*^9, 3.539878337461914*^9}}]
}, Open  ]],

Cell[BoxData[
 RowBox[{"prn", "@", 
  RowBox[{"FullCodeFormat", "@", "boxes21"}]}]], "Input",
 CellChangeTimes->{{3.5387671185058594`*^9, 3.5387671185878906`*^9}, {
   3.539878350491211*^9, 3.539878356783203*^9}, 3.540387642918293*^9}],

Cell[BoxData[
 RowBox[{"\n", 
  RowBox[{
   RowBox[{
    RowBox[{"SetAttributes", "[", 
     RowBox[{"valueQ1", ",", "HoldAll"}], "]"}], ";"}], "\n", 
   RowBox[{
    RowBox[{
     RowBox[{"valueQ1", "[", "expr_", "]"}], ":=", "\n", "\t", 
     RowBox[{"Module", "[", 
      RowBox[{
       RowBox[{"{", 
        RowBox[{"P", ",", 
         RowBox[{"R", "=", "False"}]}], "}"}], ",", "\t", "\t", "\n", "\t", 
       "\t", 
       RowBox[{
        RowBox[{"P", "=", 
         RowBox[{
          RowBox[{"(", 
           RowBox[{"P", "=", 
            RowBox[{
             RowBox[{"Return", "[", 
              RowBox[{
               RowBox[{"R", "=", "True"}], ",", "TraceScan"}], "]"}], "&"}]}],
            ")"}], "&"}]}], ";", "\n", "\t", "\t", 
        RowBox[{"TraceScan", "[", 
         RowBox[{"P", ",", "expr", ",", 
          RowBox[{"TraceDepth", "\[Rule]", "1"}]}], "]"}], ";", "\n", "\t", 
        "\t", "R"}]}], "\n", "\t", "]"}]}], ";"}], "\n", 
   RowBox[{
    RowBox[{"SetAttributes", "[", 
     RowBox[{"valueQ2", ",", "HoldAll"}], "]"}], ";"}], "\n", 
   RowBox[{
    RowBox[{
     RowBox[{"valueQ2", "[", "expr_", "]"}], ":=", "\n", "\t", 
     RowBox[{"Module", "[", 
      RowBox[{
       RowBox[{"{", 
        RowBox[{"P", ",", 
         RowBox[{"R", "=", "False"}]}], "}"}], ",", "\n", "\t", "\t", 
       RowBox[{
        RowBox[{"P", "=", 
         RowBox[{
          RowBox[{"(", 
           RowBox[{"P", "=", 
            RowBox[{
             RowBox[{"Return", "[", 
              RowBox[{
               RowBox[{"R", "=", "True"}], ",", "TraceScan"}], "]"}], "&"}]}],
            ")"}], "&"}]}], ";", 
        RowBox[{"TraceScan", "[", 
         RowBox[{"P", ",", "expr"}], "]"}], ";", "R"}]}], "\n", "\t", "]"}]}],
     ";"}], "\n", 
   RowBox[{
    RowBox[{"SetAttributes", "[", 
     RowBox[{"valueQ3", ",", "HoldAll"}], "]"}], ";"}], "\n", 
   RowBox[{
    RowBox[{"valueQ3", "[", "expr_", "]"}], ":=", "\n", "\t", 
    RowBox[{"Block", "[", 
     RowBox[{
      RowBox[{"{", "Print", "}"}], ",", "\n", "\t", "\t", 
      RowBox[{"TrueQ", "[", "\n", "\t", "\t", "\t", 
       RowBox[{"TraceScan", "[", "\n", "\t", "\t", "\t", "\t", 
        RowBox[{
         RowBox[{"Null", "&"}], ",", "expr", ",", "_", ",", 
         RowBox[{
          RowBox[{"If", "[", 
           RowBox[{
            RowBox[{"#1", "=!=", 
             TagBox["#2",
              HoldForm]}], ",", 
            RowBox[{"Return", "[", 
             RowBox[{"True", ",", "TraceScan"}], "]"}]}], "]"}], "&"}]}], 
        "\n", "\t", "\t", "\t", "]"}], "\n", "\t", "\t", "]"}]}], "\n", "\t", 
     "]"}]}]}]}]], "Input",
 GeneratedCell->True,
 CellAutoOverwrite->True,
 CellChangeTimes->{3.5398783531914062`*^9}],

Cell[BoxData[
 RowBox[{"prn", "@", 
  RowBox[{"FullCodeFormatCompact", "@", "boxes21"}]}]], "Input",
 CellChangeTimes->{{3.5398783688759766`*^9, 3.5398783699658203`*^9}, 
   3.54038764296078*^9}],

Cell[BoxData[
 RowBox[{"\n", 
  RowBox[{
   RowBox[{
    RowBox[{"SetAttributes", "[", 
     RowBox[{"valueQ1", ",", "HoldAll"}], "]"}], ";"}], "\n", 
   RowBox[{
    RowBox[{
     RowBox[{"valueQ1", "[", "expr_", "]"}], ":=", "\n", "\t", 
     RowBox[{"Module", "[", 
      RowBox[{
       RowBox[{"{", 
        RowBox[{"P", ",", 
         RowBox[{"R", "=", "False"}]}], "}"}], ",", "\t", "\t", "\n", "\t", 
       "\t", 
       RowBox[{
        RowBox[{"P", "=", 
         RowBox[{
          RowBox[{"(", 
           RowBox[{"P", "=", 
            RowBox[{
             RowBox[{"Return", "[", 
              RowBox[{
               RowBox[{"R", "=", "True"}], ",", "TraceScan"}], "]"}], "&"}]}],
            ")"}], "&"}]}], ";", "\n", "\t", "\t", 
        RowBox[{"TraceScan", "[", 
         RowBox[{"P", ",", "expr", ",", 
          RowBox[{"TraceDepth", "\[Rule]", "1"}]}], "]"}], ";", "\n", "\t", 
        "\t", "R"}]}], "]"}]}], ";"}], "\n", 
   RowBox[{
    RowBox[{"SetAttributes", "[", 
     RowBox[{"valueQ2", ",", "HoldAll"}], "]"}], ";"}], "\n", 
   RowBox[{
    RowBox[{
     RowBox[{"valueQ2", "[", "expr_", "]"}], ":=", "\n", "\t", 
     RowBox[{"Module", "[", 
      RowBox[{
       RowBox[{"{", 
        RowBox[{"P", ",", 
         RowBox[{"R", "=", "False"}]}], "}"}], ",", "\n", "\t", "\t", 
       RowBox[{
        RowBox[{"P", "=", 
         RowBox[{
          RowBox[{"(", 
           RowBox[{"P", "=", 
            RowBox[{
             RowBox[{"Return", "[", 
              RowBox[{
               RowBox[{"R", "=", "True"}], ",", "TraceScan"}], "]"}], "&"}]}],
            ")"}], "&"}]}], ";", 
        RowBox[{"TraceScan", "[", 
         RowBox[{"P", ",", "expr"}], "]"}], ";", "R"}]}], "]"}]}], ";"}], 
   "\n", 
   RowBox[{
    RowBox[{"SetAttributes", "[", 
     RowBox[{"valueQ3", ",", "HoldAll"}], "]"}], ";"}], "\n", 
   RowBox[{
    RowBox[{"valueQ3", "[", "expr_", "]"}], ":=", "\n", "\t", 
    RowBox[{"Block", "[", 
     RowBox[{
      RowBox[{"{", "Print", "}"}], ",", "\n", "\t", "\t", 
      RowBox[{"TrueQ", "[", "\n", "\t", "\t", "\t", 
       RowBox[{"TraceScan", "[", "\n", "\t", "\t", "\t", "\t", 
        RowBox[{
         RowBox[{"Null", "&"}], ",", "expr", ",", "_", ",", 
         RowBox[{
          RowBox[{"If", "[", 
           RowBox[{
            RowBox[{"#1", "=!=", 
             TagBox["#2",
              HoldForm]}], ",", 
            RowBox[{"Return", "[", 
             RowBox[{"True", ",", "TraceScan"}], "]"}]}], "]"}], "&"}]}], 
        "]"}], "]"}]}], "]"}]}]}]}]], "Input",
 GeneratedCell->True,
 CellAutoOverwrite->True,
 CellChangeTimes->{3.53987837065625*^9}]
}, Closed]],

Cell[CellGroupData[{

Cell["Example20", "Subsubsection",
 CellChangeTimes->{{3.5391997029625626`*^9, 3.5391997041861954`*^9}, 
   3.540401585164133*^9}],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"boxes22", " ", "=", " ", 
  RowBox[{"MakeBoxes", "[", 
   RowBox[{
    RowBox[{"Clear", "[", "getSamples", "]"}], ";", "\n", 
    RowBox[{
     RowBox[{"getSamples", "[", 
      RowBox[{"data_List", ",", 
       RowBox[{"minlen_Integer", "?", "Positive"}], ",", 
       RowBox[{"n", ":", 
        RowBox[{
         RowBox[{"(", 
          RowBox[{"_Integer", "|", "All"}], ")"}], ":", "All"}]}]}], "]"}], ":=", 
     RowBox[{"ReplaceList", "[", 
      RowBox[{"data", ",", 
       RowBox[{
        RowBox[{"{", 
         RowBox[{"x___", ",", 
          RowBox[{"p", ":", 
           RowBox[{"Repeated", "[", 
            RowBox[{
             RowBox[{"Except", "[", 
              RowBox[{"0", "|", "Null"}], "]"}], ",", 
             RowBox[{"{", 
              RowBox[{"minlen", ",", "Infinity"}], "}"}]}], "]"}]}], ",", 
          "___"}], "}"}], "\[RuleDelayed]", 
        RowBox[{"{", 
         RowBox[{
          RowBox[{"{", "p", "}"}], ",", 
          RowBox[{"Length", "[", 
           RowBox[{
            RowBox[{"{", "x", "}"}], "+", "1"}], "]"}]}], "}"}]}], ",", 
       RowBox[{"If", "[", 
        RowBox[{
         RowBox[{"n", "===", "All"}], ",", 
         RowBox[{"Sequence", "@@", 
          RowBox[{"{", "}"}]}], ",", "n"}], "]"}]}], "]"}]}]}], 
   "]"}]}]], "Input",
 CellChangeTimes->{{3.538767269629883*^9, 3.5387672886914062`*^9}, 
   3.5387673397246094`*^9, 3.538767374705078*^9}],

Cell[BoxData[
 RowBox[{"RowBox", "[", 
  RowBox[{"{", 
   RowBox[{
    RowBox[{"RowBox", "[", 
     RowBox[{"{", 
      RowBox[{"\<\"Clear\"\>", ",", "\<\"[\"\>", ",", "\<\"getSamples\"\>", 
       ",", "\<\"]\"\>"}], "}"}], "]"}], ",", "\<\";\"\>", ",", 
    RowBox[{"RowBox", "[", 
     RowBox[{"{", 
      RowBox[{
       RowBox[{"RowBox", "[", 
        RowBox[{"{", 
         RowBox[{"\<\"getSamples\"\>", ",", "\<\"[\"\>", ",", 
          RowBox[{"RowBox", "[", 
           RowBox[{"{", 
            RowBox[{"\<\"data_List\"\>", ",", "\<\",\"\>", ",", 
             RowBox[{"RowBox", "[", 
              RowBox[{"{", 
               
               RowBox[{"\<\"minlen_Integer\"\>", ",", "\<\"?\"\>", 
                ",", "\<\"Positive\"\>"}], "}"}], "]"}], ",", "\<\",\"\>", 
             ",", 
             RowBox[{"RowBox", "[", 
              RowBox[{"{", 
               RowBox[{"\<\"n\"\>", ",", "\<\":\"\>", ",", 
                RowBox[{"RowBox", "[", 
                 RowBox[{"{", 
                  
                  RowBox[{"\<\"_Integer\"\>", ",", "\<\"|\"\>", 
                   ",", "\<\"All\"\>"}], "}"}], "]"}], ",", "\<\":\"\>", 
                ",", "\<\"All\"\>"}], "}"}], "]"}]}], "}"}], "]"}], 
          ",", "\<\"]\"\>"}], "}"}], "]"}], ",", "\<\":=\"\>", ",", 
       RowBox[{"RowBox", "[", 
        RowBox[{"{", 
         RowBox[{"\<\"ReplaceList\"\>", ",", "\<\"[\"\>", ",", 
          RowBox[{"RowBox", "[", 
           RowBox[{"{", 
            RowBox[{"\<\"data\"\>", ",", "\<\",\"\>", ",", 
             RowBox[{"RowBox", "[", 
              RowBox[{"{", 
               RowBox[{
                RowBox[{"RowBox", "[", 
                 RowBox[{"{", 
                  RowBox[{"\<\"{\"\>", ",", 
                   RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"x___\"\>", ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"p\"\>", ",", "\<\":\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"Repeated\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"Except\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"0\"\>", ",", "\<\"|\"\>", 
                    ",", "\<\"Null\"\>"}], "}"}], "]"}], ",", "\<\"]\"\>"}], 
                    "}"}], "]"}], ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"{\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"minlen\"\>", ",", "\<\",\"\>", 
                    ",", "\<\"\[Infinity]\"\>"}], "}"}], "]"}], 
                    ",", "\<\"}\"\>"}], "}"}], "]"}]}], "}"}], "]"}], 
                    ",", "\<\"]\"\>"}], "}"}], "]"}]}], "}"}], "]"}], 
                    ",", "\<\",\"\>", ",", "\<\"___\"\>"}], "}"}], "]"}], 
                   ",", "\<\"}\"\>"}], "}"}], "]"}], 
                ",", "\<\"\[RuleDelayed]\"\>", ",", 
                RowBox[{"RowBox", "[", 
                 RowBox[{"{", 
                  RowBox[{"\<\"{\"\>", ",", 
                   RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"{\"\>", ",", "\<\"p\"\>", ",", "\<\"}\"\>"}],
                     "}"}], "]"}], ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"Length\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"{\"\>", ",", "\<\"x\"\>", ",", "\<\"}\"\>"}],
                     "}"}], "]"}], ",", "\<\"+\"\>", ",", "\<\"1\"\>"}], 
                    "}"}], "]"}], ",", "\<\"]\"\>"}], "}"}], "]"}]}], "}"}], 
                    "]"}], ",", "\<\"}\"\>"}], "}"}], "]"}]}], "}"}], "]"}], 
             ",", "\<\",\"\>", ",", 
             RowBox[{"RowBox", "[", 
              RowBox[{"{", 
               RowBox[{"\<\"If\"\>", ",", "\<\"[\"\>", ",", 
                RowBox[{"RowBox", "[", 
                 RowBox[{"{", 
                  RowBox[{
                   RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"n\"\>", ",", "\<\"===\"\>", 
                    ",", "\<\"All\"\>"}], "}"}], "]"}], ",", "\<\",\"\>", ",", 
                   RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"Sequence\"\>", ",", "\<\"@@\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"{\"\>", ",", "\<\"}\"\>"}], "}"}], "]"}]}], 
                    "}"}], "]"}], ",", "\<\",\"\>", ",", "\<\"n\"\>"}], "}"}],
                  "]"}], ",", "\<\"]\"\>"}], "}"}], "]"}]}], "}"}], "]"}], 
          ",", "\<\"]\"\>"}], "}"}], "]"}]}], "}"}], "]"}]}], "}"}], 
  "]"}]], "Output",
 CellChangeTimes->{3.5387672890634766`*^9, 3.5387673754414062`*^9, 
  3.5391997062242813`*^9, 3.5398783965009766`*^9}]
}, Open  ]],

Cell[BoxData[
 RowBox[{"prn", "@", 
  RowBox[{"FullCodeFormat", "@", "boxes22"}]}]], "Input",
 CellChangeTimes->{{3.5387673866503906`*^9, 3.5387673921845703`*^9}, {
   3.539878400569336*^9, 3.5398784025615234`*^9}, 3.540387643007776*^9}],

Cell[BoxData[
 RowBox[{"\n", 
  RowBox[{
   RowBox[{
    RowBox[{"Clear", "[", "getSamples", "]"}], ";"}], "\n", 
   RowBox[{
    RowBox[{"getSamples", "[", 
     RowBox[{"data_List", ",", 
      RowBox[{"minlen_Integer", "?", "Positive"}], ",", 
      RowBox[{"n", ":", 
       RowBox[{"_Integer", "|", "All"}], ":", "All"}]}], "]"}], ":=", "\n", 
    "\t", 
    RowBox[{"ReplaceList", "[", "\t", "\t", "\n", "\t", "\t", 
     RowBox[{"data", ",", "\n", "\t", "\t", 
      RowBox[{
       RowBox[{"{", 
        RowBox[{"x___", ",", 
         RowBox[{"p", ":", 
          RowBox[{"Repeated", "[", 
           RowBox[{
            RowBox[{"Except", "[", 
             RowBox[{"0", "|", "Null"}], "]"}], ",", 
            RowBox[{"{", 
             RowBox[{"minlen", ",", "\[Infinity]"}], "}"}]}], "]"}]}], ",", 
         "___"}], "}"}], "\[RuleDelayed]", "\n", "\t", "\t", "\t", 
       RowBox[{"{", 
        RowBox[{
         RowBox[{"{", "p", "}"}], ",", 
         RowBox[{"Length", "[", 
          RowBox[{
           RowBox[{"{", "x", "}"}], "+", "1"}], "]"}]}], "}"}]}], ",", "\n", 
      "\t", "\t", 
      RowBox[{"If", "[", 
       RowBox[{
        RowBox[{"n", "===", "All"}], ",", 
        RowBox[{"Sequence", "@@", 
         RowBox[{"{", "}"}]}], ",", "n"}], "]"}]}], "\n", "\t", 
     "]"}]}]}]}]], "Input",
 GeneratedCell->True,
 CellAutoOverwrite->True,
 CellChangeTimes->{3.5398784032402344`*^9}],

Cell[BoxData[
 RowBox[{"prn", "@", 
  RowBox[{"FullCodeFormatCompact", "@", "boxes22"}]}]], "Input",
 CellChangeTimes->{{3.539878412796875*^9, 3.539878414711914*^9}, 
   3.540387643054368*^9}],

Cell[BoxData[
 RowBox[{"\n", 
  RowBox[{
   RowBox[{
    RowBox[{"Clear", "[", "getSamples", "]"}], ";"}], "\n", 
   RowBox[{
    RowBox[{"getSamples", "[", 
     RowBox[{"data_List", ",", 
      RowBox[{"minlen_Integer", "?", "Positive"}], ",", 
      RowBox[{"n", ":", 
       RowBox[{"_Integer", "|", "All"}], ":", "All"}]}], "]"}], ":=", "\n", 
    "\t", 
    RowBox[{"ReplaceList", "[", "\t", "\t", "\n", "\t", "\t", 
     RowBox[{"data", ",", "\n", "\t", "\t", 
      RowBox[{
       RowBox[{"{", 
        RowBox[{"x___", ",", 
         RowBox[{"p", ":", 
          RowBox[{"Repeated", "[", 
           RowBox[{
            RowBox[{"Except", "[", 
             RowBox[{"0", "|", "Null"}], "]"}], ",", 
            RowBox[{"{", 
             RowBox[{"minlen", ",", "\[Infinity]"}], "}"}]}], "]"}]}], ",", 
         "___"}], "}"}], "\[RuleDelayed]", "\n", "\t", "\t", "\t", 
       RowBox[{"{", 
        RowBox[{
         RowBox[{"{", "p", "}"}], ",", 
         RowBox[{"Length", "[", 
          RowBox[{
           RowBox[{"{", "x", "}"}], "+", "1"}], "]"}]}], "}"}]}], ",", "\n", 
      "\t", "\t", 
      RowBox[{"If", "[", 
       RowBox[{
        RowBox[{"n", "===", "All"}], ",", 
        RowBox[{"Sequence", "@@", 
         RowBox[{"{", "}"}]}], ",", "n"}], "]"}]}], "]"}]}]}]}]], "Input",
 GeneratedCell->True,
 CellAutoOverwrite->True,
 CellChangeTimes->{3.5398784153134766`*^9}]
}, Closed]],

Cell[CellGroupData[{

Cell["Example21", "Subsubsection",
 CellChangeTimes->{{3.539199725947914*^9, 3.5391997301529922`*^9}, 
   3.540401585824555*^9}],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"boxes23", " ", "=", " ", 
  RowBox[{"MakeBoxes", "[", 
   RowBox[{
    RowBox[{"getSamples", "[", 
     RowBox[{"data_List", ",", 
      RowBox[{"minlen_Integer", "?", "Positive"}], ",", 
      RowBox[{"n", ":", 
       RowBox[{
        RowBox[{"(", 
         RowBox[{"_Integer", "|", "All"}], ")"}], ":", "All"}]}]}], "]"}], ":=", 
    RowBox[{"Module", "[", 
     RowBox[{
      RowBox[{"{", 
       RowBox[{"da", "=", 
        RowBox[{"SplitBy", "[", 
         RowBox[{"data", ",", 
          RowBox[{
           RowBox[{"MatchQ", "[", 
            RowBox[{"#", ",", 
             RowBox[{"0", "|", "0.", "|", "Null"}]}], "]"}], "&"}]}], "]"}]}],
        "}"}], ",", 
      RowBox[{
       RowBox[{"da", "=", 
        RowBox[{
         RowBox[{"Function", "[", 
          RowBox[{"l", ",", 
           RowBox[{"Transpose", "[", 
            RowBox[{"Through", "[", 
             RowBox[{
              RowBox[{"{", 
               RowBox[{"Identity", ",", 
                RowBox[{
                 RowBox[{
                  RowBox[{"Last", "[", "l", "]"}], "+", 
                  RowBox[{"Range", "[", 
                   RowBox[{"Length", "[", "#", "]"}], "]"}], "-", "1"}], 
                 "&"}]}], "}"}], "[", 
              RowBox[{"Partition", "[", 
               RowBox[{
                RowBox[{"First", "[", "l", "]"}], ",", "minlen", ",", "1"}], 
               "]"}], "]"}], "]"}], "]"}]}], "]"}], "/@", 
         RowBox[{"Select", "[", 
          RowBox[{
           RowBox[{"Transpose", "[", 
            RowBox[{"{", 
             RowBox[{"da", ",", 
              RowBox[{
               RowBox[{
                RowBox[{"(", 
                 RowBox[{
                  RowBox[{"Accumulate", "[", "#", "]"}], "-", "#", "+", "1"}],
                  ")"}], "&"}], "[", 
               RowBox[{"Length", "/@", "da"}], "]"}]}], "}"}], "]"}], ",", 
           RowBox[{
            RowBox[{"(", 
             RowBox[{
              RowBox[{"Length", "[", 
               RowBox[{"First", "[", "#", "]"}], "]"}], "\[GreaterEqual]", 
              "minlen"}], ")"}], "&"}]}], "]"}]}]}], ";", 
       "\[IndentingNewLine]", 
       RowBox[{"Take", "[", 
        RowBox[{
         RowBox[{"Flatten", "[", 
          RowBox[{"da", ",", "1"}], "]"}], ",", "n"}], "]"}]}]}], "]"}]}], 
   "]"}]}]], "Input",
 CellChangeTimes->{{3.5387674498623047`*^9, 3.5387674583779297`*^9}}],

Cell[BoxData[
 RowBox[{"RowBox", "[", 
  RowBox[{"{", 
   RowBox[{
    RowBox[{"RowBox", "[", 
     RowBox[{"{", 
      RowBox[{"\<\"getSamples\"\>", ",", "\<\"[\"\>", ",", 
       RowBox[{"RowBox", "[", 
        RowBox[{"{", 
         RowBox[{"\<\"data_List\"\>", ",", "\<\",\"\>", ",", 
          RowBox[{"RowBox", "[", 
           RowBox[{"{", 
            
            RowBox[{"\<\"minlen_Integer\"\>", ",", "\<\"?\"\>", 
             ",", "\<\"Positive\"\>"}], "}"}], "]"}], ",", "\<\",\"\>", ",", 
          RowBox[{"RowBox", "[", 
           RowBox[{"{", 
            RowBox[{"\<\"n\"\>", ",", "\<\":\"\>", ",", 
             RowBox[{"RowBox", "[", 
              RowBox[{"{", 
               
               RowBox[{"\<\"_Integer\"\>", ",", "\<\"|\"\>", 
                ",", "\<\"All\"\>"}], "}"}], "]"}], ",", "\<\":\"\>", 
             ",", "\<\"All\"\>"}], "}"}], "]"}]}], "}"}], "]"}], 
       ",", "\<\"]\"\>"}], "}"}], "]"}], ",", "\<\":=\"\>", ",", 
    RowBox[{"RowBox", "[", 
     RowBox[{"{", 
      RowBox[{"\<\"Module\"\>", ",", "\<\"[\"\>", ",", 
       RowBox[{"RowBox", "[", 
        RowBox[{"{", 
         RowBox[{
          RowBox[{"RowBox", "[", 
           RowBox[{"{", 
            RowBox[{"\<\"{\"\>", ",", 
             RowBox[{"RowBox", "[", 
              RowBox[{"{", 
               RowBox[{"\<\"da\"\>", ",", "\<\"=\"\>", ",", 
                RowBox[{"RowBox", "[", 
                 RowBox[{"{", 
                  RowBox[{"\<\"SplitBy\"\>", ",", "\<\"[\"\>", ",", 
                   RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"data\"\>", ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"MatchQ\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"#1\"\>", ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"0\"\>", ",", "\<\"|\"\>", ",", "\<\"0.`\"\>",
                     ",", "\<\"|\"\>", ",", "\<\"Null\"\>"}], "}"}], "]"}]}], 
                    "}"}], "]"}], ",", "\<\"]\"\>"}], "}"}], "]"}], 
                    ",", "\<\"&\"\>"}], "}"}], "]"}]}], "}"}], "]"}], 
                   ",", "\<\"]\"\>"}], "}"}], "]"}]}], "}"}], "]"}], 
             ",", "\<\"}\"\>"}], "}"}], "]"}], ",", "\<\",\"\>", ",", 
          RowBox[{"RowBox", "[", 
           RowBox[{"{", 
            RowBox[{
             RowBox[{"RowBox", "[", 
              RowBox[{"{", 
               RowBox[{"\<\"da\"\>", ",", "\<\"=\"\>", ",", 
                RowBox[{"RowBox", "[", 
                 RowBox[{"{", 
                  RowBox[{
                   RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"Function\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"l\"\>", ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"Transpose\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"Through\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"{\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"Identity\"\>", ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"Last\"\>", ",", "\<\"[\"\>", 
                    ",", "\<\"l\"\>", ",", "\<\"]\"\>"}], "}"}], "]"}], 
                    ",", "\<\"+\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"Range\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"Length\"\>", ",", "\<\"[\"\>", 
                    ",", "\<\"#1\"\>", ",", "\<\"]\"\>"}], "}"}], "]"}], 
                    ",", "\<\"]\"\>"}], "}"}], "]"}], ",", "\<\"-\"\>", 
                    ",", "\<\"1\"\>"}], "}"}], "]"}], ",", "\<\"&\"\>"}], 
                    "}"}], "]"}]}], "}"}], "]"}], ",", "\<\"}\"\>"}], "}"}], 
                    "]"}], ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"Partition\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"First\"\>", ",", "\<\"[\"\>", 
                    ",", "\<\"l\"\>", ",", "\<\"]\"\>"}], "}"}], "]"}], 
                    ",", "\<\",\"\>", ",", "\<\"minlen\"\>", ",", "\<\",\"\>",
                     ",", "\<\"1\"\>"}], "}"}], "]"}], ",", "\<\"]\"\>"}], 
                    "}"}], "]"}], ",", "\<\"]\"\>"}], "}"}], "]"}], 
                    ",", "\<\"]\"\>"}], "}"}], "]"}], ",", "\<\"]\"\>"}], 
                    "}"}], "]"}]}], "}"}], "]"}], ",", "\<\"]\"\>"}], "}"}], 
                    "]"}], ",", "\<\"/@\"\>", ",", 
                   RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"Select\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"Transpose\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"{\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"da\"\>", ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"(\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"Accumulate\"\>", ",", "\<\"[\"\>", 
                    ",", "\<\"#1\"\>", ",", "\<\"]\"\>"}], "}"}], "]"}], 
                    ",", "\<\"-\"\>", ",", "\<\"#1\"\>", ",", "\<\"+\"\>", 
                    ",", "\<\"1\"\>"}], "}"}], "]"}], ",", "\<\"&\"\>"}], 
                    "}"}], "]"}], ",", "\<\")\"\>"}], "}"}], "]"}], 
                    ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"Length\"\>", ",", "\<\"/@\"\>", 
                    ",", "\<\"da\"\>"}], "}"}], "]"}], ",", "\<\"]\"\>"}], 
                    "}"}], "]"}]}], "}"}], "]"}], ",", "\<\"}\"\>"}], "}"}], 
                    "]"}], ",", "\<\"]\"\>"}], "}"}], "]"}], ",", "\<\",\"\>",
                     ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"Length\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"First\"\>", ",", "\<\"[\"\>", 
                    ",", "\<\"#1\"\>", ",", "\<\"]\"\>"}], "}"}], "]"}], 
                    ",", "\<\"]\"\>"}], "}"}], "]"}], 
                    ",", "\<\"\[GreaterEqual]\"\>", ",", "\<\"minlen\"\>"}], 
                    "}"}], "]"}], ",", "\<\"&\"\>"}], "}"}], "]"}]}], "}"}], 
                    "]"}], ",", "\<\"]\"\>"}], "}"}], "]"}]}], "}"}], "]"}]}],
                "}"}], "]"}], ",", "\<\";\"\>", ",", 
             RowBox[{"RowBox", "[", 
              RowBox[{"{", 
               RowBox[{"\<\"Take\"\>", ",", "\<\"[\"\>", ",", 
                RowBox[{"RowBox", "[", 
                 RowBox[{"{", 
                  RowBox[{
                   RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"Flatten\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"da\"\>", ",", "\<\",\"\>", 
                    ",", "\<\"1\"\>"}], "}"}], "]"}], ",", "\<\"]\"\>"}], 
                    "}"}], "]"}], ",", "\<\",\"\>", ",", "\<\"n\"\>"}], "}"}],
                  "]"}], ",", "\<\"]\"\>"}], "}"}], "]"}]}], "}"}], "]"}]}], 
         "}"}], "]"}], ",", "\<\"]\"\>"}], "}"}], "]"}]}], "}"}], 
  "]"}]], "Output",
 CellChangeTimes->{3.5387674588066406`*^9, 3.539199739982094*^9, 
  3.539878428854492*^9, 3.539878558602539*^9}]
}, Open  ]],

Cell[BoxData[
 RowBox[{"prn", "@", 
  RowBox[{"FullCodeFormat", "@", "boxes23"}]}]], "Input",
 CellChangeTimes->{{3.5387674669072266`*^9, 3.5387674669960938`*^9}, {
   3.539878434044922*^9, 3.539878435850586*^9}, 3.540387643096606*^9}],

Cell[BoxData[
 RowBox[{
  RowBox[{"getSamples", "[", 
   RowBox[{"data_List", ",", 
    RowBox[{"minlen_Integer", "?", "Positive"}], ",", 
    RowBox[{"n", ":", 
     RowBox[{"_Integer", "|", "All"}], ":", "All"}]}], "]"}], ":=", "\n", 
  "\t", 
  RowBox[{"Module", "[", 
   RowBox[{
    RowBox[{"{", 
     RowBox[{"da", "=", 
      RowBox[{"SplitBy", "[", 
       RowBox[{"data", ",", 
        RowBox[{
         RowBox[{"MatchQ", "[", 
          RowBox[{"#1", ",", 
           RowBox[{"0", "|", "0.`", "|", "Null"}]}], "]"}], "&"}]}], "]"}]}], 
     "}"}], ",", "\t", "\t", "\n", "\t", "\t", 
    RowBox[{
     RowBox[{"da", "=", "\n", "\t", "\t", "\t", 
      RowBox[{
       RowBox[{
       "Function", "[", "\t", "\t", "\t", "\t", "\n", "\t", "\t", "\t", "\t", 
        
        RowBox[{"l", ",", "\n", "\t", "\t", "\t", "\t", 
         RowBox[{"Transpose", "[", "\n", "\t", "\t", "\t", "\t", "\t", 
          RowBox[{"Through", "[", "\n", "\t", "\t", "\t", "\t", "\t", "\t", 
           RowBox[{
            RowBox[{"{", 
             RowBox[{"Identity", ",", 
              RowBox[{
               RowBox[{
                RowBox[{"Last", "[", "l", "]"}], "+", 
                RowBox[{"Range", "[", 
                 RowBox[{"Length", "[", "#1", "]"}], "]"}], "-", "1"}], 
               "&"}]}], "}"}], "[", "\n", "\t", "\t", "\t", "\t", "\t", "\t", 
            "\t", 
            RowBox[{"Partition", "[", 
             RowBox[{
              RowBox[{"First", "[", "l", "]"}], ",", "minlen", ",", "1"}], 
             "]"}], "\n", "\t", "\t", "\t", "\t", "\t", "\t", "]"}], "\n", 
           "\t", "\t", "\t", "\t", "\t", "]"}], "\n", "\t", "\t", "\t", "\t", 
          "]"}]}], "\n", "\t", "\t", "\t", "]"}], "/@", "\n", "\t", "\t", 
       "\t", "\t", 
       RowBox[{
       "Select", "[", "\t", "\t", "\t", "\t", "\t", "\n", "\t", "\t", "\t", 
        "\t", "\t", 
        RowBox[{
         RowBox[{"Transpose", "[", 
          RowBox[{"{", 
           RowBox[{"da", ",", 
            RowBox[{
             RowBox[{"(", 
              RowBox[{
               RowBox[{
                RowBox[{"Accumulate", "[", "#1", "]"}], "-", "#1", "+", "1"}],
                "&"}], ")"}], "[", 
             RowBox[{"Length", "/@", "da"}], "]"}]}], "}"}], "]"}], ",", "\n",
          "\t", "\t", "\t", "\t", "\t", 
         RowBox[{
          RowBox[{
           RowBox[{"Length", "[", 
            RowBox[{"First", "[", "#1", "]"}], "]"}], "\[GreaterEqual]", 
           "minlen"}], "&"}]}], "\n", "\t", "\t", "\t", "\t", "]"}]}]}], ";", 
     "\n", "\t", "\t", 
     RowBox[{"Take", "[", 
      RowBox[{
       RowBox[{"Flatten", "[", 
        RowBox[{"da", ",", "1"}], "]"}], ",", "n"}], "]"}]}]}], "\n", "\t", 
   "]"}]}]], "Input",
 GeneratedCell->True,
 CellAutoOverwrite->True,
 CellChangeTimes->{3.539878436642578*^9}],

Cell[BoxData[
 RowBox[{"prn", "@", 
  RowBox[{"FullCodeFormatCompact", "@", "boxes23"}]}]], "Input",
 CellChangeTimes->{{3.539878446076172*^9, 3.53987844715625*^9}, 
   3.540387643142851*^9}],

Cell[BoxData[
 RowBox[{
  RowBox[{"getSamples", "[", 
   RowBox[{"data_List", ",", 
    RowBox[{"minlen_Integer", "?", "Positive"}], ",", 
    RowBox[{"n", ":", 
     RowBox[{"_Integer", "|", "All"}], ":", "All"}]}], "]"}], ":=", "\n", 
  "\t", 
  RowBox[{"Module", "[", 
   RowBox[{
    RowBox[{"{", 
     RowBox[{"da", "=", 
      RowBox[{"SplitBy", "[", 
       RowBox[{"data", ",", 
        RowBox[{
         RowBox[{"MatchQ", "[", 
          RowBox[{"#1", ",", 
           RowBox[{"0", "|", "0.`", "|", "Null"}]}], "]"}], "&"}]}], "]"}]}], 
     "}"}], ",", "\t", "\t", "\n", "\t", "\t", 
    RowBox[{
     RowBox[{"da", "=", "\n", "\t", "\t", "\t", 
      RowBox[{
       RowBox[{
       "Function", "[", "\t", "\t", "\t", "\t", "\n", "\t", "\t", "\t", "\t", 
        
        RowBox[{"l", ",", "\n", "\t", "\t", "\t", "\t", 
         RowBox[{"Transpose", "[", "\n", "\t", "\t", "\t", "\t", "\t", 
          RowBox[{"Through", "[", "\n", "\t", "\t", "\t", "\t", "\t", "\t", 
           RowBox[{
            RowBox[{"{", 
             RowBox[{"Identity", ",", 
              RowBox[{
               RowBox[{
                RowBox[{"Last", "[", "l", "]"}], "+", 
                RowBox[{"Range", "[", 
                 RowBox[{"Length", "[", "#1", "]"}], "]"}], "-", "1"}], 
               "&"}]}], "}"}], "[", "\n", "\t", "\t", "\t", "\t", "\t", "\t", 
            "\t", 
            RowBox[{"Partition", "[", 
             RowBox[{
              RowBox[{"First", "[", "l", "]"}], ",", "minlen", ",", "1"}], 
             "]"}], "]"}], "]"}], "]"}]}], "]"}], "/@", "\n", "\t", "\t", 
       "\t", "\t", 
       RowBox[{
       "Select", "[", "\t", "\t", "\t", "\t", "\t", "\n", "\t", "\t", "\t", 
        "\t", "\t", 
        RowBox[{
         RowBox[{"Transpose", "[", 
          RowBox[{"{", 
           RowBox[{"da", ",", 
            RowBox[{
             RowBox[{"(", 
              RowBox[{
               RowBox[{
                RowBox[{"Accumulate", "[", "#1", "]"}], "-", "#1", "+", "1"}],
                "&"}], ")"}], "[", 
             RowBox[{"Length", "/@", "da"}], "]"}]}], "}"}], "]"}], ",", "\n",
          "\t", "\t", "\t", "\t", "\t", 
         RowBox[{
          RowBox[{
           RowBox[{"Length", "[", 
            RowBox[{"First", "[", "#1", "]"}], "]"}], "\[GreaterEqual]", 
           "minlen"}], "&"}]}], "]"}]}]}], ";", "\n", "\t", "\t", 
     RowBox[{"Take", "[", 
      RowBox[{
       RowBox[{"Flatten", "[", 
        RowBox[{"da", ",", "1"}], "]"}], ",", "n"}], "]"}]}]}], 
   "]"}]}]], "Input",
 GeneratedCell->True,
 CellAutoOverwrite->True,
 CellChangeTimes->{3.5398784478339844`*^9}]
}, Closed]],

Cell[CellGroupData[{

Cell["Example22", "Subsubsection",
 CellChangeTimes->{{3.53919979395475*^9, 3.5391997948531876`*^9}, 
   3.540401586508403*^9}],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"boxes24", " ", "=", " ", 
  RowBox[{"MakeBoxes", "[", 
   RowBox[{
    RowBox[{"getSamples", "[", 
     RowBox[{"data_List", ",", 
      RowBox[{"minlen_Integer", "?", "Positive"}], ",", 
      RowBox[{"n", ":", 
       RowBox[{
        RowBox[{"(", 
         RowBox[{"_Integer", "|", "All"}], ")"}], ":", "All"}]}]}], "]"}], ":=", 
    RowBox[{"Module", "[", 
     RowBox[{
      RowBox[{"{", 
       RowBox[{"spl", "=", 
        RowBox[{"SplitBy", "[", 
         RowBox[{"data", ",", 
          RowBox[{
           RowBox[{"MatchQ", "[", 
            RowBox[{"#", ",", 
             RowBox[{"0", "|", "0.", "|", "Null"}]}], "]"}], "&"}]}], "]"}]}],
        "}"}], ",", 
      RowBox[{"Take", "[", 
       RowBox[{
        RowBox[{"Select", "[", 
         RowBox[{
          RowBox[{"Transpose", "[", 
           RowBox[{"{", 
            RowBox[{"spl", ",", 
             RowBox[{
              RowBox[{
               RowBox[{"(", 
                RowBox[{
                 RowBox[{"Accumulate", "[", "#", "]"}], "-", "#", "+", "1"}], 
                ")"}], "&"}], "[", 
              RowBox[{"Length", "/@", "spl"}], "]"}]}], "}"}], "]"}], ",", 
          RowBox[{
           RowBox[{"(", 
            RowBox[{
             RowBox[{"Length", "[", 
              RowBox[{"First", "[", "#", "]"}], "]"}], "\[GreaterEqual]", 
             "minlen"}], ")"}], "&"}]}], "]"}], ",", "n"}], "]"}]}], "]"}]}], 
   "]"}]}]], "Input",
 CellChangeTimes->{{3.5387675390654297`*^9, 3.538767553370117*^9}}],

Cell[BoxData[
 RowBox[{"RowBox", "[", 
  RowBox[{"{", 
   RowBox[{
    RowBox[{"RowBox", "[", 
     RowBox[{"{", 
      RowBox[{"\<\"getSamples\"\>", ",", "\<\"[\"\>", ",", 
       RowBox[{"RowBox", "[", 
        RowBox[{"{", 
         RowBox[{"\<\"data_List\"\>", ",", "\<\",\"\>", ",", 
          RowBox[{"RowBox", "[", 
           RowBox[{"{", 
            
            RowBox[{"\<\"minlen_Integer\"\>", ",", "\<\"?\"\>", 
             ",", "\<\"Positive\"\>"}], "}"}], "]"}], ",", "\<\",\"\>", ",", 
          RowBox[{"RowBox", "[", 
           RowBox[{"{", 
            RowBox[{"\<\"n\"\>", ",", "\<\":\"\>", ",", 
             RowBox[{"RowBox", "[", 
              RowBox[{"{", 
               
               RowBox[{"\<\"_Integer\"\>", ",", "\<\"|\"\>", 
                ",", "\<\"All\"\>"}], "}"}], "]"}], ",", "\<\":\"\>", 
             ",", "\<\"All\"\>"}], "}"}], "]"}]}], "}"}], "]"}], 
       ",", "\<\"]\"\>"}], "}"}], "]"}], ",", "\<\":=\"\>", ",", 
    RowBox[{"RowBox", "[", 
     RowBox[{"{", 
      RowBox[{"\<\"Module\"\>", ",", "\<\"[\"\>", ",", 
       RowBox[{"RowBox", "[", 
        RowBox[{"{", 
         RowBox[{
          RowBox[{"RowBox", "[", 
           RowBox[{"{", 
            RowBox[{"\<\"{\"\>", ",", 
             RowBox[{"RowBox", "[", 
              RowBox[{"{", 
               RowBox[{"\<\"spl\"\>", ",", "\<\"=\"\>", ",", 
                RowBox[{"RowBox", "[", 
                 RowBox[{"{", 
                  RowBox[{"\<\"SplitBy\"\>", ",", "\<\"[\"\>", ",", 
                   RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"data\"\>", ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"MatchQ\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"#1\"\>", ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"0\"\>", ",", "\<\"|\"\>", ",", "\<\"0.`\"\>",
                     ",", "\<\"|\"\>", ",", "\<\"Null\"\>"}], "}"}], "]"}]}], 
                    "}"}], "]"}], ",", "\<\"]\"\>"}], "}"}], "]"}], 
                    ",", "\<\"&\"\>"}], "}"}], "]"}]}], "}"}], "]"}], 
                   ",", "\<\"]\"\>"}], "}"}], "]"}]}], "}"}], "]"}], 
             ",", "\<\"}\"\>"}], "}"}], "]"}], ",", "\<\",\"\>", ",", 
          RowBox[{"RowBox", "[", 
           RowBox[{"{", 
            RowBox[{"\<\"Take\"\>", ",", "\<\"[\"\>", ",", 
             RowBox[{"RowBox", "[", 
              RowBox[{"{", 
               RowBox[{
                RowBox[{"RowBox", "[", 
                 RowBox[{"{", 
                  RowBox[{"\<\"Select\"\>", ",", "\<\"[\"\>", ",", 
                   RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"Transpose\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"{\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"spl\"\>", ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"(\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"Accumulate\"\>", ",", "\<\"[\"\>", 
                    ",", "\<\"#1\"\>", ",", "\<\"]\"\>"}], "}"}], "]"}], 
                    ",", "\<\"-\"\>", ",", "\<\"#1\"\>", ",", "\<\"+\"\>", 
                    ",", "\<\"1\"\>"}], "}"}], "]"}], ",", "\<\"&\"\>"}], 
                    "}"}], "]"}], ",", "\<\")\"\>"}], "}"}], "]"}], 
                    ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"Length\"\>", ",", "\<\"/@\"\>", 
                    ",", "\<\"spl\"\>"}], "}"}], "]"}], ",", "\<\"]\"\>"}], 
                    "}"}], "]"}]}], "}"}], "]"}], ",", "\<\"}\"\>"}], "}"}], 
                    "]"}], ",", "\<\"]\"\>"}], "}"}], "]"}], ",", "\<\",\"\>",
                     ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"Length\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"First\"\>", ",", "\<\"[\"\>", 
                    ",", "\<\"#1\"\>", ",", "\<\"]\"\>"}], "}"}], "]"}], 
                    ",", "\<\"]\"\>"}], "}"}], "]"}], 
                    ",", "\<\"\[GreaterEqual]\"\>", ",", "\<\"minlen\"\>"}], 
                    "}"}], "]"}], ",", "\<\"&\"\>"}], "}"}], "]"}]}], "}"}], 
                    "]"}], ",", "\<\"]\"\>"}], "}"}], "]"}], ",", "\<\",\"\>",
                 ",", "\<\"n\"\>"}], "}"}], "]"}], ",", "\<\"]\"\>"}], "}"}], 
           "]"}]}], "}"}], "]"}], ",", "\<\"]\"\>"}], "}"}], "]"}]}], "}"}], 
  "]"}]], "Output",
 CellChangeTimes->{3.5387675538603516`*^9, 3.539199799935219*^9, 
  3.539878569088867*^9}]
}, Open  ]],

Cell[BoxData[
 RowBox[{"prn", "@", 
  RowBox[{"FullCodeFormat", "@", "boxes24"}]}]], "Input",
 CellChangeTimes->{{3.538767560515625*^9, 3.5387675606689453`*^9}, {
   3.539878574084961*^9, 3.539878575642578*^9}, 3.540387643186356*^9}],

Cell[BoxData[
 RowBox[{
  RowBox[{"getSamples", "[", 
   RowBox[{"data_List", ",", 
    RowBox[{"minlen_Integer", "?", "Positive"}], ",", 
    RowBox[{"n", ":", 
     RowBox[{"_Integer", "|", "All"}], ":", "All"}]}], "]"}], ":=", "\n", 
  "\t", 
  RowBox[{"Module", "[", 
   RowBox[{
    RowBox[{"{", 
     RowBox[{"spl", "=", 
      RowBox[{"SplitBy", "[", 
       RowBox[{"data", ",", 
        RowBox[{
         RowBox[{"MatchQ", "[", 
          RowBox[{"#1", ",", 
           RowBox[{"0", "|", "0.`", "|", "Null"}]}], "]"}], "&"}]}], "]"}]}], 
     "}"}], ",", "\n", "\t", "\t", 
    RowBox[{"Take", "[", "\t", "\t", "\t", "\n", "\t", "\t", "\t", 
     RowBox[{
      RowBox[{
      "Select", "[", "\t", "\t", "\t", "\t", "\n", "\t", "\t", "\t", "\t", 
       RowBox[{
        RowBox[{"Transpose", "[", 
         RowBox[{"{", 
          RowBox[{"spl", ",", 
           RowBox[{
            RowBox[{"(", 
             RowBox[{
              RowBox[{
               RowBox[{"Accumulate", "[", "#1", "]"}], "-", "#1", "+", "1"}], 
              "&"}], ")"}], "[", 
            RowBox[{"Length", "/@", "spl"}], "]"}]}], "}"}], "]"}], ",", "\n",
         "\t", "\t", "\t", "\t", 
        RowBox[{
         RowBox[{
          RowBox[{"Length", "[", 
           RowBox[{"First", "[", "#1", "]"}], "]"}], "\[GreaterEqual]", 
          "minlen"}], "&"}]}], "\n", "\t", "\t", "\t", "]"}], ",", "\n", "\t",
       "\t", "\t", "n"}], "\n", "\t", "\t", "]"}]}], "\n", "\t", 
   "]"}]}]], "Input",
 GeneratedCell->True,
 CellAutoOverwrite->True,
 CellChangeTimes->{3.5398785763085938`*^9}],

Cell[BoxData[
 RowBox[{"prn", "@", 
  RowBox[{"FullCodeFormatCompact", "@", "boxes24"}]}]], "Input",
 CellChangeTimes->{{3.5398785869052734`*^9, 3.5398785880009766`*^9}, 
   3.540387643229218*^9}],

Cell[BoxData[
 RowBox[{
  RowBox[{"getSamples", "[", 
   RowBox[{"data_List", ",", 
    RowBox[{"minlen_Integer", "?", "Positive"}], ",", 
    RowBox[{"n", ":", 
     RowBox[{"_Integer", "|", "All"}], ":", "All"}]}], "]"}], ":=", "\n", 
  "\t", 
  RowBox[{"Module", "[", 
   RowBox[{
    RowBox[{"{", 
     RowBox[{"spl", "=", 
      RowBox[{"SplitBy", "[", 
       RowBox[{"data", ",", 
        RowBox[{
         RowBox[{"MatchQ", "[", 
          RowBox[{"#1", ",", 
           RowBox[{"0", "|", "0.`", "|", "Null"}]}], "]"}], "&"}]}], "]"}]}], 
     "}"}], ",", "\n", "\t", "\t", 
    RowBox[{"Take", "[", "\t", "\t", "\t", "\n", "\t", "\t", "\t", 
     RowBox[{
      RowBox[{
      "Select", "[", "\t", "\t", "\t", "\t", "\n", "\t", "\t", "\t", "\t", 
       RowBox[{
        RowBox[{"Transpose", "[", 
         RowBox[{"{", 
          RowBox[{"spl", ",", 
           RowBox[{
            RowBox[{"(", 
             RowBox[{
              RowBox[{
               RowBox[{"Accumulate", "[", "#1", "]"}], "-", "#1", "+", "1"}], 
              "&"}], ")"}], "[", 
            RowBox[{"Length", "/@", "spl"}], "]"}]}], "}"}], "]"}], ",", "\n",
         "\t", "\t", "\t", "\t", 
        RowBox[{
         RowBox[{
          RowBox[{"Length", "[", 
           RowBox[{"First", "[", "#1", "]"}], "]"}], "\[GreaterEqual]", 
          "minlen"}], "&"}]}], "]"}], ",", "\n", "\t", "\t", "\t", "n"}], 
     "]"}]}], "]"}]}]], "Input",
 GeneratedCell->True,
 CellAutoOverwrite->True,
 CellChangeTimes->{3.5398785886035156`*^9}]
}, Closed]],

Cell[CellGroupData[{

Cell["Example23", "Subsubsection",
 CellChangeTimes->{{3.5391998175719376`*^9, 3.539199819447914*^9}, 
   3.540401587140993*^9}],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"boxes25", " ", "=", " ", 
  RowBox[{"MakeBoxes", "[", 
   RowBox[{
    RowBox[{"findLsts2", "[", 
     RowBox[{"lst_", ",", 
      RowBox[{"minLen_Integer", "?", "Positive"}], ",", "maxZeros_", ",", 
      RowBox[{"n", ":", 
       RowBox[{
        RowBox[{"(", 
         RowBox[{"_Integer", "|", "All"}], ")"}], ":", "All"}]}]}], "]"}], ":=", 
    RowBox[{"Module", "[", 
     RowBox[{
      RowBox[{"{", 
       RowBox[{"zeroLst", ",", "rangeLst"}], "}"}], ",", 
      RowBox[{
       RowBox[{"zeroLst", "=", 
        RowBox[{"Flatten", "[", 
         RowBox[{"Position", "[", 
          RowBox[{"lst", ",", 
           RowBox[{"(", 
            RowBox[{"0", "|", "0.", "|", "Null"}], ")"}]}], "]"}], "]"}]}], 
       ";", "\[IndentingNewLine]", 
       RowBox[{"If", "[", 
        RowBox[{
         RowBox[{
          RowBox[{"Length", "[", "zeroLst", "]"}], "\[LessEqual]", 
          "maxZeros"}], ",", "lst", ",", 
         RowBox[{
          RowBox[{"rangeLst", "=", 
           RowBox[{"Transpose", "[", 
            RowBox[{"{", 
             RowBox[{
              RowBox[{"Prepend", "[", 
               RowBox[{
                RowBox[{"Drop", "[", 
                 RowBox[{
                  RowBox[{"zeroLst", "+", "1"}], ",", 
                  RowBox[{"-", "maxZeros"}]}], "]"}], ",", "1"}], "]"}], ",", 
              
              RowBox[{"Append", "[", 
               RowBox[{
                RowBox[{"Drop", "[", 
                 RowBox[{
                  RowBox[{"zeroLst", "-", "1"}], ",", "maxZeros"}], "]"}], 
                ",", 
                RowBox[{"Length", "[", "lst", "]"}]}], "]"}]}], "}"}], 
            "]"}]}], ";", "\[IndentingNewLine]", 
          RowBox[{
           RowBox[{
            RowBox[{"{", 
             RowBox[{
              RowBox[{"Take", "[", 
               RowBox[{"lst", ",", "#"}], "]"}], ",", "#"}], "}"}], "&"}], "/@", 
           RowBox[{"Select", "[", 
            RowBox[{"rangeLst", ",", 
             RowBox[{
              RowBox[{
               RowBox[{"(", 
                RowBox[{
                 RowBox[{"#", "[", 
                  RowBox[{"[", "2", "]"}], "]"}], "-", 
                 RowBox[{"#", "[", 
                  RowBox[{"[", "1", "]"}], "]"}], "+", "1"}], ")"}], 
               "\[GreaterEqual]", "minLen"}], "&"}], ",", 
             RowBox[{"n", "/.", 
              RowBox[{"All", "\[Rule]", 
               RowBox[{"Sequence", "[", "]"}]}]}]}], "]"}]}]}]}], "]"}]}]}], 
     "]"}]}], "]"}]}]], "Input",
 CellChangeTimes->{{3.538767647798828*^9, 3.538767653870117*^9}}],

Cell[BoxData[
 RowBox[{"RowBox", "[", 
  RowBox[{"{", 
   RowBox[{
    RowBox[{"RowBox", "[", 
     RowBox[{"{", 
      RowBox[{"\<\"findLsts2\"\>", ",", "\<\"[\"\>", ",", 
       RowBox[{"RowBox", "[", 
        RowBox[{"{", 
         RowBox[{"\<\"lst_\"\>", ",", "\<\",\"\>", ",", 
          RowBox[{"RowBox", "[", 
           RowBox[{"{", 
            
            RowBox[{"\<\"minLen_Integer\"\>", ",", "\<\"?\"\>", 
             ",", "\<\"Positive\"\>"}], "}"}], "]"}], ",", "\<\",\"\>", 
          ",", "\<\"maxZeros_\"\>", ",", "\<\",\"\>", ",", 
          RowBox[{"RowBox", "[", 
           RowBox[{"{", 
            RowBox[{"\<\"n\"\>", ",", "\<\":\"\>", ",", 
             RowBox[{"RowBox", "[", 
              RowBox[{"{", 
               
               RowBox[{"\<\"_Integer\"\>", ",", "\<\"|\"\>", 
                ",", "\<\"All\"\>"}], "}"}], "]"}], ",", "\<\":\"\>", 
             ",", "\<\"All\"\>"}], "}"}], "]"}]}], "}"}], "]"}], 
       ",", "\<\"]\"\>"}], "}"}], "]"}], ",", "\<\":=\"\>", ",", 
    RowBox[{"RowBox", "[", 
     RowBox[{"{", 
      RowBox[{"\<\"Module\"\>", ",", "\<\"[\"\>", ",", 
       RowBox[{"RowBox", "[", 
        RowBox[{"{", 
         RowBox[{
          RowBox[{"RowBox", "[", 
           RowBox[{"{", 
            RowBox[{"\<\"{\"\>", ",", 
             RowBox[{"RowBox", "[", 
              RowBox[{"{", 
               
               RowBox[{"\<\"zeroLst\"\>", ",", "\<\",\"\>", 
                ",", "\<\"rangeLst\"\>"}], "}"}], "]"}], ",", "\<\"}\"\>"}], 
            "}"}], "]"}], ",", "\<\",\"\>", ",", 
          RowBox[{"RowBox", "[", 
           RowBox[{"{", 
            RowBox[{
             RowBox[{"RowBox", "[", 
              RowBox[{"{", 
               RowBox[{"\<\"zeroLst\"\>", ",", "\<\"=\"\>", ",", 
                RowBox[{"RowBox", "[", 
                 RowBox[{"{", 
                  RowBox[{"\<\"Flatten\"\>", ",", "\<\"[\"\>", ",", 
                   RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"Position\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"lst\"\>", ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"0\"\>", ",", "\<\"|\"\>", ",", "\<\"0.`\"\>",
                     ",", "\<\"|\"\>", ",", "\<\"Null\"\>"}], "}"}], "]"}]}], 
                    "}"}], "]"}], ",", "\<\"]\"\>"}], "}"}], "]"}], 
                   ",", "\<\"]\"\>"}], "}"}], "]"}]}], "}"}], "]"}], 
             ",", "\<\";\"\>", ",", 
             RowBox[{"RowBox", "[", 
              RowBox[{"{", 
               RowBox[{"\<\"If\"\>", ",", "\<\"[\"\>", ",", 
                RowBox[{"RowBox", "[", 
                 RowBox[{"{", 
                  RowBox[{
                   RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"Length\"\>", ",", "\<\"[\"\>", 
                    ",", "\<\"zeroLst\"\>", ",", "\<\"]\"\>"}], "}"}], "]"}], 
                    ",", "\<\"\[LessEqual]\"\>", ",", "\<\"maxZeros\"\>"}], 
                    "}"}], "]"}], ",", "\<\",\"\>", ",", "\<\"lst\"\>", 
                   ",", "\<\",\"\>", ",", 
                   RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"rangeLst\"\>", ",", "\<\"=\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"Transpose\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"{\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"Prepend\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"Drop\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"zeroLst\"\>", ",", "\<\"+\"\>", 
                    ",", "\<\"1\"\>"}], "}"}], "]"}], ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"-\"\>", ",", "\<\"maxZeros\"\>"}], "}"}], 
                    "]"}]}], "}"}], "]"}], ",", "\<\"]\"\>"}], "}"}], "]"}], 
                    ",", "\<\",\"\>", ",", "\<\"1\"\>"}], "}"}], "]"}], 
                    ",", "\<\"]\"\>"}], "}"}], "]"}], ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"Append\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"Drop\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"zeroLst\"\>", ",", "\<\"-\"\>", 
                    ",", "\<\"1\"\>"}], "}"}], "]"}], ",", "\<\",\"\>", 
                    ",", "\<\"maxZeros\"\>"}], "}"}], "]"}], 
                    ",", "\<\"]\"\>"}], "}"}], "]"}], ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"Length\"\>", ",", "\<\"[\"\>", 
                    ",", "\<\"lst\"\>", ",", "\<\"]\"\>"}], "}"}], "]"}]}], 
                    "}"}], "]"}], ",", "\<\"]\"\>"}], "}"}], "]"}]}], "}"}], 
                    "]"}], ",", "\<\"}\"\>"}], "}"}], "]"}], 
                    ",", "\<\"]\"\>"}], "}"}], "]"}]}], "}"}], "]"}], 
                    ",", "\<\";\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"(\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"{\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"Take\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"lst\"\>", ",", "\<\",\"\>", 
                    ",", "\<\"#1\"\>"}], "}"}], "]"}], ",", "\<\"]\"\>"}], 
                    "}"}], "]"}], ",", "\<\",\"\>", ",", "\<\"#1\"\>"}], 
                    "}"}], "]"}], ",", "\<\"}\"\>"}], "}"}], "]"}], 
                    ",", "\<\"&\"\>"}], "}"}], "]"}], ",", "\<\")\"\>"}], 
                    "}"}], "]"}], ",", "\<\"/@\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"Select\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"rangeLst\"\>", ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"#1\"\>", ",", "\<\"\[LeftDoubleBracket]\"\>",
                     ",", "\<\"2\"\>", ",", "\<\"\[RightDoubleBracket]\"\>"}],
                     "}"}], "]"}], ",", "\<\"-\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"#1\"\>", ",", "\<\"\[LeftDoubleBracket]\"\>",
                     ",", "\<\"1\"\>", ",", "\<\"\[RightDoubleBracket]\"\>"}],
                     "}"}], "]"}], ",", "\<\"+\"\>", ",", "\<\"1\"\>"}], 
                    "}"}], "]"}], ",", "\<\"\[GreaterEqual]\"\>", 
                    ",", "\<\"minLen\"\>"}], "}"}], "]"}], ",", "\<\"&\"\>"}],
                     "}"}], "]"}], ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"n\"\>", ",", "\<\"/.\"\>", 
                    ",", "\<\"\[InvisibleSpace]\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"All\"\>", ",", "\<\"\[Rule]\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"Sequence\"\>", ",", "\<\"[\"\>", 
                    ",", "\<\"]\"\>"}], "}"}], "]"}]}], "}"}], "]"}]}], "}"}],
                     "]"}]}], "}"}], "]"}], ",", "\<\"]\"\>"}], "}"}], 
                    "]"}]}], "}"}], "]"}]}], "}"}], "]"}]}], "}"}], "]"}], 
                ",", "\<\"]\"\>"}], "}"}], "]"}]}], "}"}], "]"}]}], "}"}], 
        "]"}], ",", "\<\"]\"\>"}], "}"}], "]"}]}], "}"}], "]"}]], "Output",
 CellChangeTimes->{3.538767654379883*^9, 3.5391998266149063`*^9, 
  3.5398786044716797`*^9}]
}, Open  ]],

Cell[BoxData[
 RowBox[{"prn", "@", 
  RowBox[{"FullCodeFormat", "@", "boxes25"}]}]], "Input",
 CellChangeTimes->{{3.5387676629414062`*^9, 3.538767663046875*^9}, {
   3.539878610161133*^9, 3.5398786117382812`*^9}, 3.540387643272505*^9}],

Cell[BoxData[
 RowBox[{
  RowBox[{"findLsts2", "[", 
   RowBox[{"lst_", ",", 
    RowBox[{"minLen_Integer", "?", "Positive"}], ",", "maxZeros_", ",", 
    RowBox[{"n", ":", 
     RowBox[{"_Integer", "|", "All"}], ":", "All"}]}], "]"}], ":=", "\n", 
  "\t", 
  RowBox[{"Module", "[", 
   RowBox[{
    RowBox[{"{", 
     RowBox[{"zeroLst", ",", "rangeLst"}], "}"}], ",", "\t", "\t", "\n", "\t",
     "\t", 
    RowBox[{
     RowBox[{"zeroLst", "=", 
      RowBox[{"Flatten", "[", 
       RowBox[{"Position", "[", 
        RowBox[{"lst", ",", 
         RowBox[{"0", "|", "0.`", "|", "Null"}]}], "]"}], "]"}]}], ";", "\n", 
     "\t", "\t", 
     RowBox[{"If", "[", "\n", "\t", "\t", "\t", 
      RowBox[{
       RowBox[{
        RowBox[{"Length", "[", "zeroLst", "]"}], "\[LessEqual]", "maxZeros"}],
        ",", "\n", "\t", "\t", "\t", "lst", ",", "\n", "\t", "\t", "\t", 
       RowBox[{"(*", " ", "else", " ", "*)"}], "\t", "\t", "\t", "\n", "\t", 
       "\t", "\t", 
       RowBox[{
        RowBox[{"rangeLst", "=", "\n", "\t", "\t", "\t", "\t", 
         RowBox[{"Transpose", "[", "\n", "\t", "\t", "\t", "\t", "\t", 
          RowBox[{
          "{", "\t", "\t", "\t", "\t", "\t", "\t", "\n", "\t", "\t", "\t", 
           "\t", "\t", "\t", 
           RowBox[{
            RowBox[{"Prepend", "[", 
             RowBox[{
              RowBox[{"Drop", "[", 
               RowBox[{
                RowBox[{"zeroLst", "+", "1"}], ",", 
                RowBox[{"-", "maxZeros"}]}], "]"}], ",", "1"}], "]"}], ",", 
            "\n", "\t", "\t", "\t", "\t", "\t", "\t", 
            RowBox[{"Append", "[", 
             RowBox[{
              RowBox[{"Drop", "[", 
               RowBox[{
                RowBox[{"zeroLst", "-", "1"}], ",", "maxZeros"}], "]"}], ",", 
              
              RowBox[{"Length", "[", "lst", "]"}]}], "]"}]}], "\n", "\t", 
           "\t", "\t", "\t", "\t", "}"}], "\n", "\t", "\t", "\t", "\t", 
          "]"}]}], ";", "\n", "\t", "\t", "\t", 
        RowBox[{
         RowBox[{"(", 
          RowBox[{
           RowBox[{"{", 
            RowBox[{
             RowBox[{"Take", "[", 
              RowBox[{"lst", ",", "#1"}], "]"}], ",", "#1"}], "}"}], "&"}], 
          ")"}], "/@", "\n", "\t", "\t", "\t", "\t", 
         RowBox[{"Select", "[", "\n", "\t", "\t", "\t", "\t", "\t", 
          RowBox[{"rangeLst", ",", 
           RowBox[{
            RowBox[{
             RowBox[{
              RowBox[{
              "#1", "\[LeftDoubleBracket]", "2", "\[RightDoubleBracket]"}], 
              "-", 
              RowBox[{
              "#1", "\[LeftDoubleBracket]", "1", "\[RightDoubleBracket]"}], 
              "+", "1"}], "\[GreaterEqual]", "minLen"}], "&"}], ",", 
           RowBox[{"n", "/.", "\[InvisibleSpace]", 
            RowBox[{"All", "\[Rule]", 
             RowBox[{"Sequence", "[", "]"}]}]}]}], "\n", "\t", "\t", "\t", 
          "\t", "]"}]}]}]}], "\n", "\t", "\t", "]"}]}]}], "\n", "\t", 
   "]"}]}]], "Input",
 GeneratedCell->True,
 CellAutoOverwrite->True,
 CellChangeTimes->{3.5398786124052734`*^9}],

Cell[BoxData[
 RowBox[{"prn", "@", 
  RowBox[{"FullCodeFormatCompact", "@", "boxes25"}]}]], "Input",
 CellChangeTimes->{{3.5398786230898438`*^9, 3.5398786241103516`*^9}, 
   3.540387643314767*^9}],

Cell[BoxData[
 RowBox[{
  RowBox[{"findLsts2", "[", 
   RowBox[{"lst_", ",", 
    RowBox[{"minLen_Integer", "?", "Positive"}], ",", "maxZeros_", ",", 
    RowBox[{"n", ":", 
     RowBox[{"_Integer", "|", "All"}], ":", "All"}]}], "]"}], ":=", "\n", 
  "\t", 
  RowBox[{"Module", "[", 
   RowBox[{
    RowBox[{"{", 
     RowBox[{"zeroLst", ",", "rangeLst"}], "}"}], ",", "\t", "\t", "\n", "\t",
     "\t", 
    RowBox[{
     RowBox[{"zeroLst", "=", 
      RowBox[{"Flatten", "[", 
       RowBox[{"Position", "[", 
        RowBox[{"lst", ",", 
         RowBox[{"0", "|", "0.`", "|", "Null"}]}], "]"}], "]"}]}], ";", "\n", 
     "\t", "\t", 
     RowBox[{"If", "[", "\n", "\t", "\t", "\t", 
      RowBox[{
       RowBox[{
        RowBox[{"Length", "[", "zeroLst", "]"}], "\[LessEqual]", "maxZeros"}],
        ",", "\n", "\t", "\t", "\t", "lst", ",", "\n", "\t", "\t", "\t", 
       RowBox[{"(*", " ", "else", " ", "*)"}], "\t", "\t", "\t", "\n", "\t", 
       "\t", "\t", 
       RowBox[{
        RowBox[{"rangeLst", "=", "\n", "\t", "\t", "\t", "\t", 
         RowBox[{"Transpose", "[", "\n", "\t", "\t", "\t", "\t", "\t", 
          RowBox[{
          "{", "\t", "\t", "\t", "\t", "\t", "\t", "\n", "\t", "\t", "\t", 
           "\t", "\t", "\t", 
           RowBox[{
            RowBox[{"Prepend", "[", 
             RowBox[{
              RowBox[{"Drop", "[", 
               RowBox[{
                RowBox[{"zeroLst", "+", "1"}], ",", 
                RowBox[{"-", "maxZeros"}]}], "]"}], ",", "1"}], "]"}], ",", 
            "\n", "\t", "\t", "\t", "\t", "\t", "\t", 
            RowBox[{"Append", "[", 
             RowBox[{
              RowBox[{"Drop", "[", 
               RowBox[{
                RowBox[{"zeroLst", "-", "1"}], ",", "maxZeros"}], "]"}], ",", 
              
              RowBox[{"Length", "[", "lst", "]"}]}], "]"}]}], "}"}], "]"}]}], 
        ";", "\n", "\t", "\t", "\t", 
        RowBox[{
         RowBox[{"(", 
          RowBox[{
           RowBox[{"{", 
            RowBox[{
             RowBox[{"Take", "[", 
              RowBox[{"lst", ",", "#1"}], "]"}], ",", "#1"}], "}"}], "&"}], 
          ")"}], "/@", "\n", "\t", "\t", "\t", "\t", 
         RowBox[{"Select", "[", "\n", "\t", "\t", "\t", "\t", "\t", 
          RowBox[{"rangeLst", ",", 
           RowBox[{
            RowBox[{
             RowBox[{
              RowBox[{
              "#1", "\[LeftDoubleBracket]", "2", "\[RightDoubleBracket]"}], 
              "-", 
              RowBox[{
              "#1", "\[LeftDoubleBracket]", "1", "\[RightDoubleBracket]"}], 
              "+", "1"}], "\[GreaterEqual]", "minLen"}], "&"}], ",", 
           RowBox[{"n", "/.", "\[InvisibleSpace]", 
            RowBox[{"All", "\[Rule]", 
             RowBox[{"Sequence", "[", "]"}]}]}]}], "]"}]}]}]}], "]"}]}]}], 
   "]"}]}]], "Input",
 GeneratedCell->True,
 CellAutoOverwrite->True,
 CellChangeTimes->{3.539878624708008*^9}]
}, Closed]],

Cell[CellGroupData[{

Cell["Example24", "Subsubsection",
 CellChangeTimes->{{3.5391998544518204`*^9, 3.5391998555250626`*^9}, 
   3.540401587803481*^9}],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"boxes26", " ", "=", " ", 
  RowBox[{"MakeBoxes", "[", 
   RowBox[{
    RowBox[{"findLsts3", "[", 
     RowBox[{"lst_", ",", 
      RowBox[{"len_Integer", "?", "Positive"}], ",", "maxZeros_", ",", 
      RowBox[{"n", ":", 
       RowBox[{
        RowBox[{"(", 
         RowBox[{"_Integer", "|", "All"}], ")"}], ":", "All"}]}]}], "]"}], ":=", 
    RowBox[{"Module", "[", 
     RowBox[{
      RowBox[{"{", 
       RowBox[{"zeroLst", ",", "rangeLst", ",", "startLst"}], "}"}], ",", 
      RowBox[{
       RowBox[{"zeroLst", "=", 
        RowBox[{"Flatten", "[", 
         RowBox[{"Position", "[", 
          RowBox[{"lst", ",", 
           RowBox[{"(", 
            RowBox[{"0", "|", "0.", "|", "Null"}], ")"}]}], "]"}], "]"}]}], 
       ";", "\[IndentingNewLine]", 
       RowBox[{"If", "[", 
        RowBox[{
         RowBox[{
          RowBox[{"Length", "[", "zeroLst", "]"}], "\[LessEqual]", 
          "maxZeros"}], ",", 
         RowBox[{"startLst", "=", 
          RowBox[{"Range", "[", 
           RowBox[{
            RowBox[{"Length", "[", "lst", "]"}], "-", "len", "+", "1"}], 
           "]"}]}], ",", 
         RowBox[{
          RowBox[{"rangeLst", "=", 
           RowBox[{"Transpose", "[", 
            RowBox[{"{", 
             RowBox[{
              RowBox[{"Prepend", "[", 
               RowBox[{
                RowBox[{"Drop", "[", 
                 RowBox[{
                  RowBox[{"zeroLst", "+", "1"}], ",", 
                  RowBox[{"-", "maxZeros"}]}], "]"}], ",", "1"}], "]"}], ",", 
              
              RowBox[{"Append", "[", 
               RowBox[{
                RowBox[{"Drop", "[", 
                 RowBox[{
                  RowBox[{"zeroLst", "-", "len"}], ",", "maxZeros"}], "]"}], 
                ",", 
                RowBox[{
                 RowBox[{"Length", "[", "lst", "]"}], "-", "len", "+", 
                 "1"}]}], "]"}]}], "}"}], "]"}]}], ";", "\[IndentingNewLine]", 
          RowBox[{"startLst", "=", 
           RowBox[{"Flatten", "[", 
            RowBox[{
             RowBox[{"Range", "@@@", 
              RowBox[{"(", 
               RowBox[{"List", "@@", 
                RowBox[{"(", 
                 RowBox[{"Interval", "@@", 
                  RowBox[{"Select", "[", 
                   RowBox[{"rangeLst", ",", 
                    RowBox[{
                    RowBox[{
                    RowBox[{"(", 
                    RowBox[{
                    RowBox[{"#", "[", 
                    RowBox[{"[", "2", "]"}], "]"}], "-", 
                    RowBox[{"#", "[", 
                    RowBox[{"[", "1", "]"}], "]"}]}], ")"}], 
                    "\[GreaterEqual]", "0"}], "&"}]}], "]"}]}], ")"}]}], 
               ")"}]}], ",", "1"}], "]"}]}]}]}], "]"}], ";", 
       "\[IndentingNewLine]", 
       RowBox[{
        RowBox[{
         RowBox[{"{", 
          RowBox[{
           RowBox[{"lst", "[", 
            RowBox[{"[", 
             RowBox[{"#", ";;", 
              RowBox[{"#", "+", "len", "-", "1"}]}], "]"}], "]"}], ",", "#"}],
           "}"}], "&"}], "/@", 
        RowBox[{"Sort", "@", 
         RowBox[{"RandomSample", "[", 
          RowBox[{"startLst", ",", "n"}], "]"}]}]}]}]}], "]"}]}], 
   "]"}]}]], "Input",
 CellChangeTimes->{{3.5387677541191406`*^9, 3.538767760951172*^9}}],

Cell[BoxData[
 RowBox[{"RowBox", "[", 
  RowBox[{"{", 
   RowBox[{
    RowBox[{"RowBox", "[", 
     RowBox[{"{", 
      RowBox[{"\<\"findLsts3\"\>", ",", "\<\"[\"\>", ",", 
       RowBox[{"RowBox", "[", 
        RowBox[{"{", 
         RowBox[{"\<\"lst_\"\>", ",", "\<\",\"\>", ",", 
          RowBox[{"RowBox", "[", 
           RowBox[{"{", 
            
            RowBox[{"\<\"len_Integer\"\>", ",", "\<\"?\"\>", 
             ",", "\<\"Positive\"\>"}], "}"}], "]"}], ",", "\<\",\"\>", 
          ",", "\<\"maxZeros_\"\>", ",", "\<\",\"\>", ",", 
          RowBox[{"RowBox", "[", 
           RowBox[{"{", 
            RowBox[{"\<\"n\"\>", ",", "\<\":\"\>", ",", 
             RowBox[{"RowBox", "[", 
              RowBox[{"{", 
               
               RowBox[{"\<\"_Integer\"\>", ",", "\<\"|\"\>", 
                ",", "\<\"All\"\>"}], "}"}], "]"}], ",", "\<\":\"\>", 
             ",", "\<\"All\"\>"}], "}"}], "]"}]}], "}"}], "]"}], 
       ",", "\<\"]\"\>"}], "}"}], "]"}], ",", "\<\":=\"\>", ",", 
    RowBox[{"RowBox", "[", 
     RowBox[{"{", 
      RowBox[{"\<\"Module\"\>", ",", "\<\"[\"\>", ",", 
       RowBox[{"RowBox", "[", 
        RowBox[{"{", 
         RowBox[{
          RowBox[{"RowBox", "[", 
           RowBox[{"{", 
            RowBox[{"\<\"{\"\>", ",", 
             RowBox[{"RowBox", "[", 
              RowBox[{"{", 
               
               RowBox[{"\<\"zeroLst\"\>", ",", "\<\",\"\>", 
                ",", "\<\"rangeLst\"\>", ",", "\<\",\"\>", 
                ",", "\<\"startLst\"\>"}], "}"}], "]"}], ",", "\<\"}\"\>"}], 
            "}"}], "]"}], ",", "\<\",\"\>", ",", 
          RowBox[{"RowBox", "[", 
           RowBox[{"{", 
            RowBox[{
             RowBox[{"RowBox", "[", 
              RowBox[{"{", 
               RowBox[{"\<\"zeroLst\"\>", ",", "\<\"=\"\>", ",", 
                RowBox[{"RowBox", "[", 
                 RowBox[{"{", 
                  RowBox[{"\<\"Flatten\"\>", ",", "\<\"[\"\>", ",", 
                   RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"Position\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"lst\"\>", ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"0\"\>", ",", "\<\"|\"\>", ",", "\<\"0.`\"\>",
                     ",", "\<\"|\"\>", ",", "\<\"Null\"\>"}], "}"}], "]"}]}], 
                    "}"}], "]"}], ",", "\<\"]\"\>"}], "}"}], "]"}], 
                   ",", "\<\"]\"\>"}], "}"}], "]"}]}], "}"}], "]"}], 
             ",", "\<\";\"\>", ",", 
             RowBox[{"RowBox", "[", 
              RowBox[{"{", 
               RowBox[{"\<\"If\"\>", ",", "\<\"[\"\>", ",", 
                RowBox[{"RowBox", "[", 
                 RowBox[{"{", 
                  RowBox[{
                   RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"Length\"\>", ",", "\<\"[\"\>", 
                    ",", "\<\"zeroLst\"\>", ",", "\<\"]\"\>"}], "}"}], "]"}], 
                    ",", "\<\"\[LessEqual]\"\>", ",", "\<\"maxZeros\"\>"}], 
                    "}"}], "]"}], ",", "\<\",\"\>", ",", 
                   RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"startLst\"\>", ",", "\<\"=\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"Range\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"Length\"\>", ",", "\<\"[\"\>", 
                    ",", "\<\"lst\"\>", ",", "\<\"]\"\>"}], "}"}], "]"}], 
                    ",", "\<\"-\"\>", ",", "\<\"len\"\>", ",", "\<\"+\"\>", 
                    ",", "\<\"1\"\>"}], "}"}], "]"}], ",", "\<\"]\"\>"}], 
                    "}"}], "]"}]}], "}"}], "]"}], ",", "\<\",\"\>", ",", 
                   RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"rangeLst\"\>", ",", "\<\"=\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"Transpose\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"{\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"Prepend\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"Drop\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"zeroLst\"\>", ",", "\<\"+\"\>", 
                    ",", "\<\"1\"\>"}], "}"}], "]"}], ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"-\"\>", ",", "\<\"maxZeros\"\>"}], "}"}], 
                    "]"}]}], "}"}], "]"}], ",", "\<\"]\"\>"}], "}"}], "]"}], 
                    ",", "\<\",\"\>", ",", "\<\"1\"\>"}], "}"}], "]"}], 
                    ",", "\<\"]\"\>"}], "}"}], "]"}], ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"Append\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"Drop\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"zeroLst\"\>", ",", "\<\"-\"\>", 
                    ",", "\<\"len\"\>"}], "}"}], "]"}], ",", "\<\",\"\>", 
                    ",", "\<\"maxZeros\"\>"}], "}"}], "]"}], 
                    ",", "\<\"]\"\>"}], "}"}], "]"}], ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"Length\"\>", ",", "\<\"[\"\>", 
                    ",", "\<\"lst\"\>", ",", "\<\"]\"\>"}], "}"}], "]"}], 
                    ",", "\<\"-\"\>", ",", "\<\"len\"\>", ",", "\<\"+\"\>", 
                    ",", "\<\"1\"\>"}], "}"}], "]"}]}], "}"}], "]"}], 
                    ",", "\<\"]\"\>"}], "}"}], "]"}]}], "}"}], "]"}], 
                    ",", "\<\"}\"\>"}], "}"}], "]"}], ",", "\<\"]\"\>"}], 
                    "}"}], "]"}]}], "}"}], "]"}], ",", "\<\";\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"startLst\"\>", ",", "\<\"=\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"Flatten\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"Apply\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"Range\"\>", ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"List\"\>", ",", "\<\"@@\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"Interval\"\>", ",", "\<\"@@\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"Select\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"rangeLst\"\>", ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"#1\"\>", ",", "\<\"\[LeftDoubleBracket]\"\>",
                     ",", "\<\"2\"\>", ",", "\<\"\[RightDoubleBracket]\"\>"}],
                     "}"}], "]"}], ",", "\<\"-\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"#1\"\>", ",", "\<\"\[LeftDoubleBracket]\"\>",
                     ",", "\<\"1\"\>", ",", "\<\"\[RightDoubleBracket]\"\>"}],
                     "}"}], "]"}]}], "}"}], "]"}], 
                    ",", "\<\"\[GreaterEqual]\"\>", ",", "\<\"0\"\>"}], "}"}],
                     "]"}], ",", "\<\"&\"\>"}], "}"}], "]"}]}], "}"}], "]"}], 
                    ",", "\<\"]\"\>"}], "}"}], "]"}]}], "}"}], "]"}]}], "}"}],
                     "]"}], ",", "\<\",\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"{\"\>", ",", "\<\"1\"\>", ",", "\<\"}\"\>"}],
                     "}"}], "]"}]}], "}"}], "]"}], ",", "\<\"]\"\>"}], "}"}], 
                    "]"}], ",", "\<\",\"\>", ",", "\<\"1\"\>"}], "}"}], "]"}],
                     ",", "\<\"]\"\>"}], "}"}], "]"}]}], "}"}], "]"}]}], 
                    "}"}], "]"}]}], "}"}], "]"}], ",", "\<\"]\"\>"}], "}"}], 
              "]"}], ",", "\<\";\"\>", ",", 
             RowBox[{"RowBox", "[", 
              RowBox[{"{", 
               RowBox[{
                RowBox[{"RowBox", "[", 
                 RowBox[{"{", 
                  RowBox[{"\<\"(\"\>", ",", 
                   RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"{\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"lst\"\>", 
                    ",", "\<\"\[LeftDoubleBracket]\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"#1\"\>", ",", "\<\";;\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"#1\"\>", ",", "\<\"+\"\>", 
                    ",", "\<\"len\"\>", ",", "\<\"-\"\>", ",", "\<\"1\"\>"}], 
                    "}"}], "]"}]}], "}"}], "]"}], 
                    ",", "\<\"\[RightDoubleBracket]\"\>"}], "}"}], "]"}], 
                    ",", "\<\",\"\>", ",", "\<\"#1\"\>"}], "}"}], "]"}], 
                    ",", "\<\"}\"\>"}], "}"}], "]"}], ",", "\<\"&\"\>"}], 
                    "}"}], "]"}], ",", "\<\")\"\>"}], "}"}], "]"}], 
                ",", "\<\"/@\"\>", ",", 
                RowBox[{"RowBox", "[", 
                 RowBox[{"{", 
                  RowBox[{"\<\"Sort\"\>", ",", "\<\"[\"\>", ",", 
                   RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    RowBox[{"\<\"RandomSample\"\>", ",", "\<\"[\"\>", ",", 
                    RowBox[{"RowBox", "[", 
                    RowBox[{"{", 
                    
                    RowBox[{"\<\"startLst\"\>", ",", "\<\",\"\>", 
                    ",", "\<\"n\"\>"}], "}"}], "]"}], ",", "\<\"]\"\>"}], 
                    "}"}], "]"}], ",", "\<\"]\"\>"}], "}"}], "]"}]}], "}"}], 
              "]"}]}], "}"}], "]"}]}], "}"}], "]"}], ",", "\<\"]\"\>"}], 
      "}"}], "]"}]}], "}"}], "]"}]], "Output",
 CellChangeTimes->{
  3.5387677614501953`*^9, 3.539199859800453*^9, {3.539878635270508*^9, 
   3.539878645875*^9}, 3.540306520722457*^9, 3.540387943479199*^9}]
}, Open  ]],

Cell[BoxData[
 RowBox[{"prn", "@", 
  RowBox[{"FullCodeFormat", "@", "boxes26"}]}]], "Input",
 CellChangeTimes->{{3.5387677694541016`*^9, 3.538767769588867*^9}, {
   3.5398786495185547`*^9, 3.539878650989258*^9}, 3.540387643335752*^9}],

Cell[BoxData[
 RowBox[{
  RowBox[{"findLsts3", "[", 
   RowBox[{"lst_", ",", 
    RowBox[{"len_Integer", "?", "Positive"}], ",", "maxZeros_", ",", 
    RowBox[{"n", ":", 
     RowBox[{"_Integer", "|", "All"}], ":", "All"}]}], "]"}], ":=", "\n", 
  "\t", 
  RowBox[{"Module", "[", 
   RowBox[{
    RowBox[{"{", 
     RowBox[{"zeroLst", ",", "rangeLst", ",", "startLst"}], "}"}], ",", "\t", 
    "\t", "\n", "\t", "\t", 
    RowBox[{
     RowBox[{"zeroLst", "=", 
      RowBox[{"Flatten", "[", 
       RowBox[{"Position", "[", 
        RowBox[{"lst", ",", 
         RowBox[{"0", "|", "0.`", "|", "Null"}]}], "]"}], "]"}]}], ";", "\n", 
     "\t", "\t", 
     RowBox[{"If", "[", "\n", "\t", "\t", "\t", 
      RowBox[{
       RowBox[{
        RowBox[{"Length", "[", "zeroLst", "]"}], "\[LessEqual]", "maxZeros"}],
        ",", "\n", "\t", "\t", "\t", 
       RowBox[{"startLst", "=", 
        RowBox[{"Range", "[", 
         RowBox[{
          RowBox[{"Length", "[", "lst", "]"}], "-", "len", "+", "1"}], 
         "]"}]}], ",", "\n", "\t", "\t", "\t", 
       RowBox[{"(*", " ", "else", " ", "*)"}], "\t", "\t", "\t", "\n", "\t", 
       "\t", "\t", 
       RowBox[{
        RowBox[{"rangeLst", "=", "\n", "\t", "\t", "\t", "\t", 
         RowBox[{"Transpose", "[", "\n", "\t", "\t", "\t", "\t", "\t", 
          RowBox[{
          "{", "\t", "\t", "\t", "\t", "\t", "\t", "\n", "\t", "\t", "\t", 
           "\t", "\t", "\t", 
           RowBox[{
            RowBox[{"Prepend", "[", 
             RowBox[{
              RowBox[{"Drop", "[", 
               RowBox[{
                RowBox[{"zeroLst", "+", "1"}], ",", 
                RowBox[{"-", "maxZeros"}]}], "]"}], ",", "1"}], "]"}], ",", 
            "\n", "\t", "\t", "\t", "\t", "\t", "\t", 
            RowBox[{
            "Append", "[", "\t", "\t", "\t", "\t", "\t", "\t", "\t", "\n", 
             "\t", "\t", "\t", "\t", "\t", "\t", "\t", 
             RowBox[{
              RowBox[{"Drop", "[", 
               RowBox[{
                RowBox[{"zeroLst", "-", "len"}], ",", "maxZeros"}], "]"}], 
              ",", "\n", "\t", "\t", "\t", "\t", "\t", "\t", "\t", 
              RowBox[{
               RowBox[{"Length", "[", "lst", "]"}], "-", "len", "+", "1"}]}], 
             "\n", "\t", "\t", "\t", "\t", "\t", "\t", "]"}]}], "\n", "\t", 
           "\t", "\t", "\t", "\t", "}"}], "\n", "\t", "\t", "\t", "\t", 
          "]"}]}], ";", "\n", "\t", "\t", "\t", 
        RowBox[{"startLst", "=", "\n", "\t", "\t", "\t", "\t", 
         RowBox[{
         "Flatten", "[", "\t", "\t", "\t", "\t", "\t", "\n", "\t", "\t", "\t",
           "\t", "\t", 
          RowBox[{
           RowBox[{
           "Apply", "[", "\t", "\t", "\t", "\t", "\t", "\t", "\n", "\t", "\t",
             "\t", "\t", "\t", "\t", 
            RowBox[{"Range", ",", "\n", "\t", "\t", "\t", "\t", "\t", "\t", 
             RowBox[{
             "List", "@@", "\n", "\t", "\t", "\t", "\t", "\t", "\t", "\t", 
              RowBox[{"Interval", "@@", 
               RowBox[{"Select", "[", 
                RowBox[{"rangeLst", ",", 
                 RowBox[{
                  RowBox[{
                   RowBox[{
                    RowBox[{
                    "#1", "\[LeftDoubleBracket]", "2", 
                    "\[RightDoubleBracket]"}], "-", 
                    RowBox[{
                    "#1", "\[LeftDoubleBracket]", "1", 
                    "\[RightDoubleBracket]"}]}], "\[GreaterEqual]", "0"}], 
                  "&"}]}], "]"}]}]}], ",", "\n", "\t", "\t", "\t", "\t", "\t",
              "\t", 
             RowBox[{"{", "1", "}"}]}], "\n", "\t", "\t", "\t", "\t", "\t", 
            "]"}], ",", "\n", "\t", "\t", "\t", "\t", "\t", "1"}], "\n", "\t",
           "\t", "\t", "\t", "]"}]}]}]}], "\n", "\t", "\t", "]"}], ";", "\n", 
     "\t", "\t", 
     RowBox[{
      RowBox[{"(", 
       RowBox[{
        RowBox[{"{", 
         RowBox[{
          RowBox[{"lst", "\[LeftDoubleBracket]", 
           RowBox[{"#1", ";;", 
            RowBox[{"#1", "+", "len", "-", "1"}]}], "\[RightDoubleBracket]"}],
           ",", "#1"}], "}"}], "&"}], ")"}], "/@", 
      RowBox[{"Sort", "[", 
       RowBox[{"RandomSample", "[", 
        RowBox[{"startLst", ",", "n"}], "]"}], "]"}]}]}]}], "\n", "\t", 
   "]"}]}]], "Input",
 GeneratedCell->True,
 CellAutoOverwrite->True,
 CellChangeTimes->{3.540387946502174*^9}],

Cell[BoxData[
 RowBox[{"prn", "@", 
  RowBox[{"FullCodeFormatCompact", "@", "boxes26"}]}]], "Input",
 CellChangeTimes->{{3.539878663254883*^9, 3.539878664288086*^9}, 
   3.540387643365438*^9}],

Cell[BoxData[
 RowBox[{
  RowBox[{"findLsts3", "[", 
   RowBox[{"lst_", ",", 
    RowBox[{"len_Integer", "?", "Positive"}], ",", "maxZeros_", ",", 
    RowBox[{"n", ":", 
     RowBox[{"_Integer", "|", "All"}], ":", "All"}]}], "]"}], ":=", "\n", 
  "\t", 
  RowBox[{"Module", "[", 
   RowBox[{
    RowBox[{"{", 
     RowBox[{"zeroLst", ",", "rangeLst", ",", "startLst"}], "}"}], ",", "\t", 
    "\t", "\n", "\t", "\t", 
    RowBox[{
     RowBox[{"zeroLst", "=", 
      RowBox[{"Flatten", "[", 
       RowBox[{"Position", "[", 
        RowBox[{"lst", ",", 
         RowBox[{"0", "|", "0.`", "|", "Null"}]}], "]"}], "]"}]}], ";", "\n", 
     "\t", "\t", 
     RowBox[{"If", "[", "\n", "\t", "\t", "\t", 
      RowBox[{
       RowBox[{
        RowBox[{"Length", "[", "zeroLst", "]"}], "\[LessEqual]", "maxZeros"}],
        ",", "\n", "\t", "\t", "\t", 
       RowBox[{"startLst", "=", 
        RowBox[{"Range", "[", 
         RowBox[{
          RowBox[{"Length", "[", "lst", "]"}], "-", "len", "+", "1"}], 
         "]"}]}], ",", "\n", "\t", "\t", "\t", 
       RowBox[{"(*", " ", "else", " ", "*)"}], "\t", "\t", "\t", "\n", "\t", 
       "\t", "\t", 
       RowBox[{
        RowBox[{"rangeLst", "=", "\n", "\t", "\t", "\t", "\t", 
         RowBox[{"Transpose", "[", "\n", "\t", "\t", "\t", "\t", "\t", 
          RowBox[{
          "{", "\t", "\t", "\t", "\t", "\t", "\t", "\n", "\t", "\t", "\t", 
           "\t", "\t", "\t", 
           RowBox[{
            RowBox[{"Prepend", "[", 
             RowBox[{
              RowBox[{"Drop", "[", 
               RowBox[{
                RowBox[{"zeroLst", "+", "1"}], ",", 
                RowBox[{"-", "maxZeros"}]}], "]"}], ",", "1"}], "]"}], ",", 
            "\n", "\t", "\t", "\t", "\t", "\t", "\t", 
            RowBox[{
            "Append", "[", "\t", "\t", "\t", "\t", "\t", "\t", "\t", "\n", 
             "\t", "\t", "\t", "\t", "\t", "\t", "\t", 
             RowBox[{
              RowBox[{"Drop", "[", 
               RowBox[{
                RowBox[{"zeroLst", "-", "len"}], ",", "maxZeros"}], "]"}], 
              ",", "\n", "\t", "\t", "\t", "\t", "\t", "\t", "\t", 
              RowBox[{
               RowBox[{"Length", "[", "lst", "]"}], "-", "len", "+", "1"}]}], 
             "]"}]}], "}"}], "]"}]}], ";", "\n", "\t", "\t", "\t", 
        RowBox[{"startLst", "=", "\n", "\t", "\t", "\t", "\t", 
         RowBox[{
         "Flatten", "[", "\t", "\t", "\t", "\t", "\t", "\n", "\t", "\t", "\t",
           "\t", "\t", 
          RowBox[{
           RowBox[{
           "Apply", "[", "\t", "\t", "\t", "\t", "\t", "\t", "\n", "\t", "\t",
             "\t", "\t", "\t", "\t", 
            RowBox[{"Range", ",", "\n", "\t", "\t", "\t", "\t", "\t", "\t", 
             RowBox[{
             "List", "@@", "\n", "\t", "\t", "\t", "\t", "\t", "\t", "\t", 
              RowBox[{"Interval", "@@", 
               RowBox[{"Select", "[", 
                RowBox[{"rangeLst", ",", 
                 RowBox[{
                  RowBox[{
                   RowBox[{
                    RowBox[{
                    "#1", "\[LeftDoubleBracket]", "2", 
                    "\[RightDoubleBracket]"}], "-", 
                    RowBox[{
                    "#1", "\[LeftDoubleBracket]", "1", 
                    "\[RightDoubleBracket]"}]}], "\[GreaterEqual]", "0"}], 
                  "&"}]}], "]"}]}]}], ",", "\n", "\t", "\t", "\t", "\t", "\t",
              "\t", 
             RowBox[{"{", "1", "}"}]}], "]"}], ",", "\n", "\t", "\t", "\t", 
           "\t", "\t", "1"}], "]"}]}]}]}], "]"}], ";", "\n", "\t", "\t", 
     RowBox[{
      RowBox[{"(", 
       RowBox[{
        RowBox[{"{", 
         RowBox[{
          RowBox[{"lst", "\[LeftDoubleBracket]", 
           RowBox[{"#1", ";;", 
            RowBox[{"#1", "+", "len", "-", "1"}]}], "\[RightDoubleBracket]"}],
           ",", "#1"}], "}"}], "&"}], ")"}], "/@", 
      RowBox[{"Sort", "[", 
       RowBox[{"RandomSample", "[", 
        RowBox[{"startLst", ",", "n"}], "]"}], "]"}]}]}]}], "]"}]}]], "Input",\

 GeneratedCell->True,
 CellAutoOverwrite->True,
 CellChangeTimes->{3.540387953651981*^9}]
}, Closed]]
}, Open  ]]
},
WindowSize->{1920, 1005},
WindowMargins->{{0, Automatic}, {Automatic, 0}},
Magnification:>FEPrivate`If[
  FEPrivate`Equal[FEPrivate`$VersionNumber, 6.], 1.5, 1.5 Inherited],
FrontEndVersion->"8.0 for Linux x86 (32-bit) (October 10, 2011)",
StyleDefinitions->"Default.nb"
]
(* End of Notebook Content *)

(* Internal cache information *)
(*CellTagsOutline
CellTagsIndex->{}
*)
(*CellTagsIndex
CellTagsIndex->{}
*)
(*NotebookFileOutline
Notebook[{
Cell[CellGroupData[{
Cell[579, 22, 232, 4, 108, "Section"],
Cell[814, 28, 258, 5, 42, "Text"],
Cell[1075, 35, 239, 5, 43, "Input",
 InitializationCell->True],
Cell[1317, 42, 281, 9, 43, "Input",
 InitializationCell->True],
Cell[CellGroupData[{
Cell[1623, 55, 161, 3, 40, "Subsubsection"],
Cell[1787, 60, 965, 26, 98, "Input"],
Cell[2755, 88, 815, 23, 179, "Input"]
}, Closed]],
Cell[CellGroupData[{
Cell[3607, 116, 127, 2, 30, "Subsubsection"],
Cell[CellGroupData[{
Cell[3759, 122, 796, 21, 125, "Input"],
Cell[4558, 145, 2689, 62, 98, "Output"]
}, Open  ]],
Cell[7262, 210, 359, 6, 43, "Input"],
Cell[7624, 218, 754, 21, 179, "Input"],
Cell[8381, 241, 194, 4, 43, "Input"],
Cell[8578, 247, 743, 21, 152, "Input"]
}, Closed]],
Cell[CellGroupData[{
Cell[9358, 273, 129, 2, 30, "Subsubsection"],
Cell[CellGroupData[{
Cell[9512, 279, 3984, 96, 368, "Input"],
Cell[13499, 377, 14476, 310, 368, "Output"]
}, Open  ]],
Cell[27990, 690, 211, 5, 43, "Input"],
Cell[28204, 697, 4924, 114, 989, "Input"],
Cell[33131, 813, 193, 4, 43, "Input"],
Cell[33327, 819, 4751, 113, 800, "Input"]
}, Closed]],
Cell[CellGroupData[{
Cell[38115, 937, 129, 2, 30, "Subsubsection"],
Cell[CellGroupData[{
Cell[38269, 943, 1331, 36, 127, "Input"],
Cell[39603, 981, 5649, 126, 206, "Output"]
}, Open  ]],
Cell[45267, 1110, 234, 4, 43, "Input"],
Cell[45504, 1116, 1358, 39, 235, "Input"],
Cell[46865, 1157, 193, 4, 43, "Input"],
Cell[47061, 1163, 1346, 39, 208, "Input"]
}, Closed]],
Cell[CellGroupData[{
Cell[48444, 1207, 129, 2, 30, "Subsubsection"],
Cell[CellGroupData[{
Cell[48598, 1213, 2728, 69, 180, "Input"],
Cell[51329, 1284, 10359, 223, 260, "Output"]
}, Open  ]],
Cell[61703, 1510, 153, 4, 43, "Input"],
Cell[61859, 1516, 96, 1, 43, "Input"],
Cell[61958, 1519, 208, 4, 43, "Input"],
Cell[62169, 1525, 3059, 76, 559, "Input"],
Cell[65231, 1603, 193, 4, 43, "Input"],
Cell[65427, 1609, 2908, 74, 424, "Input"]
}, Closed]],
Cell[CellGroupData[{
Cell[68372, 1688, 125, 2, 30, "Subsubsection"],
Cell[CellGroupData[{
Cell[68522, 1694, 1207, 27, 281, "Input"],
Cell[69732, 1723, 4404, 97, 125, "Output"]
}, Open  ]],
Cell[74151, 1823, 210, 4, 43, "Input"],
Cell[74364, 1829, 1612, 38, 503, "Input"],
Cell[75979, 1869, 195, 4, 43, "Input"],
Cell[76177, 1875, 1513, 36, 392, "Input"]
}, Closed]],
Cell[CellGroupData[{
Cell[77727, 1916, 127, 2, 30, "Subsubsection"],
Cell[77857, 1920, 1807, 44, 179, "Input"],
Cell[CellGroupData[{
Cell[79689, 1968, 1586, 40, 152, "Input"],
Cell[81278, 2010, 7083, 156, 206, "Output"]
}, Open  ]],
Cell[88376, 2169, 232, 4, 43, "Input"],
Cell[88611, 2175, 2142, 52, 557, "Input"],
Cell[90756, 2229, 193, 4, 43, "Input"],
Cell[90952, 2235, 2075, 52, 476, "Input"]
}, Closed]],
Cell[CellGroupData[{
Cell[93064, 2292, 127, 2, 30, "Subsubsection"],
Cell[CellGroupData[{
Cell[93216, 2298, 643, 19, 71, "Input"],
Cell[93862, 2319, 2478, 56, 71, "Output"]
}, Open  ]],
Cell[96355, 2378, 214, 5, 43, "Input"],
Cell[96572, 2385, 627, 19, 206, "Input"],
Cell[97202, 2406, 195, 4, 43, "Input"],
Cell[97400, 2412, 607, 19, 152, "Input"]
}, Closed]],
Cell[CellGroupData[{
Cell[98044, 2436, 129, 2, 30, "Subsubsection"],
Cell[CellGroupData[{
Cell[98198, 2442, 1138, 34, 611, "Input"],
Cell[99339, 2478, 4945, 111, 758, "Output"]
}, Open  ]],
Cell[104299, 2592, 211, 5, 268, "Input"],
Cell[104513, 2599, 1185, 35, 1426, "Input"],
Cell[105701, 2636, 192, 4, 268, "Input"],
Cell[105896, 2642, 1181, 35, 1265, "Input"]
}, Closed]],
Cell[CellGroupData[{
Cell[107114, 2682, 129, 2, 30, "Subsubsection"],
Cell[CellGroupData[{
Cell[107268, 2688, 1334, 34, 780, "Input"],
Cell[108605, 2724, 5944, 126, 1079, "Output"]
}, Open  ]],
Cell[114564, 2853, 232, 4, 268, "Input"],
Cell[114799, 2859, 2030, 47, 3537, "Input"],
Cell[116832, 2908, 193, 4, 268, "Input"],
Cell[117028, 2914, 1864, 45, 2531, "Input"]
}, Closed]],
Cell[CellGroupData[{
Cell[118929, 2964, 130, 2, 30, "Subsubsection"],
Cell[CellGroupData[{
Cell[119084, 2970, 951, 28, 611, "Input"],
Cell[120038, 3000, 4634, 102, 919, "Output"]
}, Open  ]],
Cell[124687, 3105, 275, 6, 442, "Input"],
Cell[124965, 3113, 1177, 33, 1621, "Input"],
Cell[126145, 3148, 234, 6, 442, "Input"],
Cell[126382, 3156, 1117, 32, 1109, "Input"]
}, Closed]],
Cell[CellGroupData[{
Cell[127536, 3193, 130, 2, 30, "Subsubsection"],
Cell[CellGroupData[{
Cell[127691, 3199, 1259, 30, 949, "Input"],
Cell[128953, 3231, 4708, 104, 919, "Output"]
}, Open  ]],
Cell[133676, 3338, 231, 4, 268, "Input"],
Cell[133910, 3344, 1893, 42, 3463, "Input"],
Cell[135806, 3388, 191, 4, 268, "Input"],
Cell[136000, 3394, 1757, 41, 2622, "Input"]
}, Closed]],
Cell[CellGroupData[{
Cell[137794, 3440, 128, 2, 30, "Subsubsection"],
Cell[CellGroupData[{
Cell[137947, 3446, 4418, 105, 3121, "Input"],
Cell[142368, 3553, 14004, 312, 3181, "Output"]
}, Open  ]],
Cell[156387, 3868, 233, 4, 268, "Input"],
Cell[156623, 3874, 6386, 132, 8995, "Input"],
Cell[163012, 4008, 196, 4, 268, "Input"],
Cell[163211, 4014, 6142, 128, 7655, "Input"]
}, Closed]],
Cell[CellGroupData[{
Cell[169390, 4147, 127, 2, 30, "Subsubsection"],
Cell[CellGroupData[{
Cell[169542, 4153, 946, 24, 780, "Input"],
Cell[170491, 4179, 3725, 84, 593, "Output"]
}, Open  ]],
Cell[174231, 4266, 237, 4, 268, "Input"],
Cell[174471, 4272, 848, 26, 780, "Input"],
Cell[175322, 4300, 192, 4, 268, "Input"],
Cell[175517, 4306, 848, 26, 780, "Input"]
}, Closed]],
Cell[CellGroupData[{
Cell[176402, 4337, 128, 2, 30, "Subsubsection"],
Cell[CellGroupData[{
Cell[176555, 4343, 5917, 143, 2288, "Input"],
Cell[182475, 4488, 23183, 492, 3342, "Output"]
}, Open  ]],
Cell[205673, 4983, 273, 6, 442, "Input"],
Cell[205949, 4991, 7956, 182, 9216, "Input"],
Cell[213908, 5175, 232, 6, 442, "Input"],
Cell[214143, 5183, 7760, 180, 7898, "Input"]
}, Closed]],
Cell[CellGroupData[{
Cell[221940, 5368, 128, 2, 30, "Subsubsection"],
Cell[CellGroupData[{
Cell[222093, 5374, 1765, 46, 1109, "Input"],
Cell[223861, 5422, 7418, 166, 1235, "Output"]
}, Open  ]],
Cell[231294, 5591, 237, 4, 268, "Input"],
Cell[231534, 5597, 1862, 50, 2119, "Input"],
Cell[233399, 5649, 194, 4, 268, "Input"],
Cell[233596, 5655, 1850, 50, 1950, "Input"]
}, Closed]],
Cell[CellGroupData[{
Cell[235483, 5710, 174, 2, 30, "Subsubsection"],
Cell[CellGroupData[{
Cell[235682, 5716, 831, 22, 442, "Input"],
Cell[236516, 5740, 2380, 56, 593, "Output"]
}, Open  ]],
Cell[238911, 5799, 290, 5, 268, "Input"],
Cell[239204, 5806, 718, 21, 1109, "Input"],
Cell[239925, 5829, 196, 4, 268, "Input"],
Cell[240124, 5835, 718, 21, 1109, "Input"]
}, Closed]],
Cell[CellGroupData[{
Cell[240879, 5861, 128, 2, 30, "Subsubsection"],
Cell[CellGroupData[{
Cell[241032, 5867, 3103, 75, 1781, "Input"],
Cell[244138, 5944, 11916, 257, 2046, "Output"]
}, Open  ]],
Cell[256069, 6204, 237, 4, 268, "Input"],
Cell[256309, 6210, 4269, 96, 4972, "Input"],
Cell[260581, 6308, 194, 4, 268, "Input"],
Cell[260778, 6314, 3985, 93, 3793, "Input"]
}, Closed]],
Cell[CellGroupData[{
Cell[264800, 6412, 128, 2, 30, "Subsubsection"],
Cell[CellGroupData[{
Cell[264953, 6418, 4617, 125, 3463, "Input"],
Cell[269573, 6545, 19857, 457, 3342, "Output"]
}, Open  ]],
Cell[289445, 7005, 232, 4, 268, "Input"],
Cell[289680, 7011, 5313, 143, 7655, "Input"],
Cell[294996, 7156, 196, 4, 268, "Input"],
Cell[295195, 7162, 5149, 142, 6142, "Input"]
}, Closed]],
Cell[CellGroupData[{
Cell[300381, 7309, 130, 2, 30, "Subsubsection"],
Cell[CellGroupData[{
Cell[300536, 7315, 2711, 73, 2791, "Input"],
Cell[303250, 7390, 10457, 236, 1885, "Output"]
}, Open  ]],
Cell[313722, 7629, 235, 4, 268, "Input"],
Cell[313960, 7635, 2715, 77, 3793, "Input"],
Cell[316678, 7714, 195, 4, 268, "Input"],
Cell[316876, 7720, 2627, 76, 2960, "Input"]
}, Closed]],
Cell[CellGroupData[{
Cell[319540, 7801, 130, 2, 30, "Subsubsection"],
Cell[CellGroupData[{
Cell[319695, 7807, 1429, 39, 645, "Input"],
Cell[321127, 7848, 5651, 124, 1079, "Output"]
}, Open  ]],
Cell[326793, 7975, 237, 4, 268, "Input"],
Cell[327033, 7981, 1410, 40, 1625, "Input"],
Cell[328446, 8023, 192, 4, 268, "Input"],
Cell[328641, 8029, 1392, 39, 1465, "Input"]
}, Closed]],
Cell[CellGroupData[{
Cell[330070, 8073, 128, 2, 30, "Subsubsection"],
Cell[CellGroupData[{
Cell[330223, 8079, 2412, 66, 1140, "Input"],
Cell[332638, 8147, 9901, 214, 1720, "Output"]
}, Open  ]],
Cell[342554, 8364, 235, 4, 268, "Input"],
Cell[342792, 8370, 2828, 73, 3307, "Input"],
Cell[345623, 8445, 191, 4, 268, "Input"],
Cell[345817, 8451, 2627, 70, 2297, "Input"]
}, Closed]],
Cell[CellGroupData[{
Cell[348481, 8526, 127, 2, 30, "Subsubsection"],
Cell[CellGroupData[{
Cell[348633, 8532, 1520, 43, 801, "Input"],
Cell[350156, 8577, 5995, 133, 1079, "Output"]
}, Open  ]],
Cell[356166, 8713, 233, 4, 268, "Input"],
Cell[356402, 8719, 1578, 44, 1794, "Input"],
Cell[357983, 8765, 196, 4, 268, "Input"],
Cell[358182, 8771, 1519, 43, 1296, "Input"]
}, Closed]],
Cell[CellGroupData[{
Cell[359738, 8819, 128, 2, 30, "Subsubsection"],
Cell[CellGroupData[{
Cell[359891, 8825, 2591, 69, 971, "Input"],
Cell[362485, 8896, 10267, 222, 1560, "Output"]
}, Open  ]],
Cell[372767, 9121, 235, 4, 268, "Input"],
Cell[373005, 9127, 3059, 76, 3476, "Input"],
Cell[376067, 9205, 196, 4, 268, "Input"],
Cell[376266, 9211, 2906, 74, 2635, "Input"]
}, Closed]],
Cell[CellGroupData[{
Cell[379209, 9290, 130, 2, 30, "Subsubsection"],
Cell[CellGroupData[{
Cell[379364, 9296, 3300, 88, 312, "Input"],
Cell[382667, 9386, 13094, 278, 512, "Output"]
}, Open  ]],
Cell[395776, 9667, 235, 4, 65, "Input"],
Cell[396014, 9673, 4353, 103, 1244, "Input"],
Cell[400370, 9778, 192, 4, 65, "Input"],
Cell[400565, 9784, 4106, 99, 960, "Input"]
}, Closed]]
}, Open  ]]
}
]
*)

(* End of internal cache information *)
